0 votes

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.

asked Jun 12 in Engine by Aracnido (12 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')
answered Jun 12 by Dlean Jeans (3,505 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.