Animated hurt and hitboxes (SOLVED)

So I want to make hitboxes and hurtboxes that follow the different animations of my character, like you’d see in any basic fighting game like street fighter. I thought I could use the collision object components in my game objects and add or edit the different object component shapes during runtime but this doesn’t seem to be possible. My only guess is to implement my own hitbox system, but if there’s a built-in way of doing this then I’d like to know about it.

1 Like

Hi!

I think it should be possible to do by using stuff like;

  • Having collision object act as “hitboxes” by using the “trigger” type.
  • Enable/disable the collision objects at runtime, for hitboxes that should only be available during specific times of an animation.
  • “Move” collision objects" by having them under different gameobjects. (If you are using Spine characters , these objects can be then childed to different bones/slots.)
3 Likes

Thanks!

1 Like

Also this recent post on fighting games: Fighter game , but how?

1 Like

Sven suggested putting the collision object under different game objects if I wanted to move them. I’ve been giving it some thought and doing this means that I have to change the position of hitboxes through displacement in code. I would expect this to be hard to visualize and therefore make it difficult to do precise changes.

I thought that instead of moving hitboxes I can just have more collision objects that I enable/disable at runtime. So I enable the second collision object for the current frame while I disable the first collision object for the previous frame instead of moving one collision object. I don’t expect there to be an issue with rapid on-off switching of triggers in defold but if there is than I would appreciate someone givving me a heads-up here.

Doing it like this I won’t actually need multiple game objects, because all the hitboxes are just enabled/disabled instead of being moved. The big issue with this is that I can imagine is that having hitboxes for every animation in a single game object would make it chaotic/clustered/hard to manage. I can’t see a way of making folder inside of a game object. Maybe I should create a post asking for that in feature request. Either way I would imagine it being easier to manage many collision objects in a single game object instead of managing multiple game objects with multiple collision objects. Another issue is that all collision objects are displayed in a game object file. This would make it horrible to look at. Can you disable collision shape preview for selected collision objects in a game object?

Another idea I had was to make a game object for each animation with fitting collision objects. But I think I’m being stupid and not keeping it simple with this one.

1 Like

Not yet, but hopefully eventually.

Disabling / enabling collision objects rapidly should not be an issue, but you should make a minimal example of what you want on your own first to make sure before investing too much into it.

Making your own hitbox editor with your own data type for hitboxes and collision detection method is also always an option.

1 Like

This functionality has been designed by @Axel but not yet implemented by @mats.gisselson and @Erik_Angelin in the editor. It will hopefully be implemented later this year.

2 Likes

Thanks for the replies. You’re all so helpful! I’ve been thinking of making my own hitbox editor but I’ve been trying to learn how to do stuff the easy way for once :joy: I’m just making a prototype “game” for now so I guess that would be the same as doing a minimal example. If it doesn’t work out I guess I’ll just have to make my own hitbox editor, seems like fun.

Super cool that the functionality for disabling collision preview has already been designed! I’ll eagerly await it’s implementation.

2 Likes

Hello again, I was close to finishing my hitbox system but then ran into the problem of flipping my collision objects when I flip my sprite. I can’t do this: Flip whole Game Object because you can’t set the position of collision objects programatically. I also can’t rotate the game object because of this issue: Is it the physic body rotation issue? (DEF-1117)

The only solution I can think of is either making a new game object for every collision object so that I can do it like the first link showed or making duplicates for every collision object and disable/enable the right one depending on direction. Neither of these solution sound attractive… Is there a simpler way? Outside of making my own hitbox editor (which I’m starting to lean towards now).

Should I instead make a new post for this question? It’s not really about animated hitboxes anymore, can I mark this post as solved somehow?

You could have your player object as a collection instead of a single game object and put the hit boxes in their own game objects. That in itself has some issues with collisions and how you propagate those, so it is a cumbersome solution.

I think “Is it the physic body rotation issue? (DEF-1117)” is a reasonable solution to your problem and something we need to look into. I would suggest that you post a message in that thread stating that you would also benefit from getting that issue solved. I’ll talk to the team and check how complex DEF-1117 is when I’m back at the office tomorrow.

The only thing we do is to edit the title and add a “(SOLVED)” text at the end.