Godot 4.3
If you want to check out the game, it’s on here: Game Link
player.gd
class_name PlayerCharacter
extends CharacterBody2D
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
#preload VFX scene
const DARK_VFX_1_SCENE:PackedScene = preload("res://Scenes/VFX/dark_vfx_1.tscn")
#vfx variable declaration
@onready var DARK_VFX_1_INSTANCE:Node = DARK_VFX_1_SCENE.instantiate()
@onready var vfx_anim:AnimatedSprite2D = DARK_VFX_1_INSTANCE.get_node("%Dark_VFX")
func _ready() -> void:
add_child(DARK_VFX_1_INSTANCE)
var player_position = GlobalVariables.player1.position
DARK_VFX_1_INSTANCE.position = player_position + Vector2(50, 0)
func _physics_process(delta: float) -> void:
if str(vfx_anim.animation) != "attack1_vfx_dark":
vfx_anim.frame = 0
vfx_anim.play("attack1_vfx_dark")
vfx_anim.visible = false
print(vfx_anim.animation)
else:
vfx_anim.visible = true
func attack1_func() -> void:
var overlapping_enemies1 = $"hitbox-attack1".get_overlapping_bodies()
hit_enemies.clear()
await get_tree().create_timer(0.28).timeout
for enemy in overlapping_enemies1:
if is_instance_valid(enemy) and enemy.is_in_group("Enemies"):
#var enemy = body.get_parent() # If you need to check the parent
if enemy not in hit_enemies:
# Add the enemy to the hit list
hit_enemies.append(enemy)
if enemy.has_method("take_damage"):
#if animated_sprite.animation == "attack1":
##print(animated_sprite.frame)
#if animated_sprite.frame == 4:
#hitbox_attack1_left1.disabled = false
#hitbox_attack1_right1.disabled = false
#else:
#hitbox_attack1_left1.disabled = true
#hitbox_attack1_right1.disabled = true
#await get_tree().create_timer(0.3).timeout
#if hitbox1_ended:
#enemy.take_damage(damage_amount_attack1)
#hitbox_waiter.connect("timeout", Callable(self, "_on_hitbox_waiter_1_timeout").bind(enemy, damage_amount_attack1))
enemy.take_damage(damage_amount_attack1)
vfx_anim.frame = 0
vfx_anim.play("attack1_vfx_dark") #VFX
#print("played")
HitStopManager.hit_stop_short()
print("Enemy took damage: ", damage_amount_attack1)
#print("Playing VFX for enemy: ", enemy.name)
else:
print("Object is not in the Enemies group, it is: ", enemy.get_class(), " with name: ", enemy.name)
when I do attack1_func, the vfx doesn’t work.
I also turned on autoplay on load and looping, so I’m sure it’s not working. also all the instances and variables are correct ,I checked all of them repeatedly.