+1 vote

I am making a 2d metroidvania. And right now I have made the typical movements, fully animated and they work. I also have melee attacks working. Now I have been using the sprite frame animation (not the animation player route) as I was following the tutorial by UmaiPixel and found it very easy. Now I am facing some big problems and I dont know what to do.

  1. I have a sliding mechanic implemented with the animated already in there but how do I change the collider on the player for specific animation i.e the collider is half its height when player is sliding.

  2. I have the attack animations but I want to implement hitboxes for each specific attack, like one attack is a slightly longer ranged than the the other. Again I dont know how to make these hitboxes which are specific to each attack animation and frame.

Any help would be greatly appreciated.

in Engine by (13 points)

1 Answer

0 votes

You can scale your CollisionShape2D:

$CollisionShape2D.scale.x = 1.25 # 25% longer

Note that you can't scale Circle or Capsule shapes so you gotta use a Rectangle shape. You will probably need to position the shape, too.

What I would do is to save the scale and position of the CollisionShape2D in an AnimationPlayer with animation length of 0 or 0.1, optionally blend between them, then call them like this:

$AnimationPlayer.play('normal_attack')

$AnimationPlayer.play('long_attack')

$AnimationPlayer.play('idle')

$AnimationPlayer.play('dash')
by (4,005 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.