I was tinkering with some souls like mechanics and tried to implement a dodge roll
seen some examples online that go way to deep into animation player
but the way I got it to work (for now) is just changing the collision layer on the character node during the roll sate, change it back when leaving it.
while having death actors mask to a specific collision layer.
this works but seems too simple. I was wondering what might be the down sides of this and what is the best approach for implementing this ?
P.S : new to Godot, so for anything Godot specific, details are appreciated
Sounds like a reasonable enough way to do it, just make sure the collision layer for “getting hit” is separate from the collision layer for “not falling through floors and walls”
A very common and more flexible approach is to use hitboxes and hurtboxes. I’m not sure on the Godot specifics of this, but the idea is that each character has “hurtbox” CollisionAreas which can be driven by their animations/states (for example turning them on and off, changing their shapes and scaling them), and weapons and projectiles have “hitbox” CollisionAreas which can be driven in the same way. If a hitbox touches your hurtbox - you get hit and it hurts!
The reason I say it’s more flexible is that it allows you to tune their sizes and shapes to support your intended game feel. For example, by making enemy hitboxes and player hurtboxes relatively small, you can make your player feel they are skillfully dodging and getting many near misses. By making enemy hurtboxes large, you can make the player like a pro sniper even if their aim is actually a little wonky. Go too far though and players might notice, and get all miffed.
I don’t have any specific technical advice on how best to do this, but I imagine there are plenty of resources online about it.
edit: Just thought - if you are turning collisions back on when the roll animation ends (or at a specific point in the animation) make sure you also turn it on if the animation is cancelled or prematurely ended some other way (for example by entering a fall state). Otherwise you may end up with incorporeal characters which can’t be hit until they dodge again. As fun as that would be, it’s probably not what you want.