Topic was automatically imported from the old Question2Answer platform.
Asked By
Kinross07
So like many before me I’ve been following and playing along with HeartBeast’s Action RPG tutorial. I’m still pretty new to scripting in general so trying to understand why things aren’t working before moving on to the next step and hoping I can fix it later.
Things that I know are different between my code and his:
Addition of $Sprite.play because otherwise it never animated
move_and_slide() changed so it should just be its own line
queue_free() present just for confirming that the hitbox detection works (it does) and layers are correct
_process instead of _physics_process - another user said this worked for them, but no difference either way.
If your issue is that the knockback isn’t working it is because your knockback_vector is Vector2.ZERO so no matter what you multiply it by it will still be (0, 0). You are also immediately calling queue_free() on the Bat so you really wouldn’t even see any knockback anyway.
If it were me in this case I would remove the knockback_vector. Then, on the Bat scene make a Timer node and call it DespawnTimer or whatever suits you. Set the delay on the timer to be around like 0.5 seconds and enable the One Shot tick box. After this you should connect the timeout() signal to your Bat code.
Then what you would probably want to do is something along the lines of this in the Bat code: