Collision Object per Animation

I have a sprite with multiple animations attached to a game object. Is it possible to automatically choose which collision object is active depending on which sprite animation is active?

You would have to send enable and disable messages to the different collision objects based on the current animation.

1 Like

My use case is for items that the player can collect. There are about 20 such items. I considered one game object for each item and 20 factories for the game objects. But I thought it might be cleaner to use one game object and change the sprites and collision objects at creation time depending on what the object is. Though that would require at least 19 messages to disable all of the unused collision objects. Does anyone have any experience with this or thoughts about which way is preferred?

Are the collision shapes really that different among the items? Or could you use a more generic collision shape?

I suppose I might be trying to be too exact and can get away with a generic shape, at least for prototyping. But for the sake of knowledge, let’s say not, then is one one clearly better than the other in your opinion.

On a side note, if sprites built from tile sheets (with automatic boundary detection) were supported then I believe that would be a very clean implementation. Is that something that might happen in the future?

It’s still an interesting topic about both enabling/disabling collision shapes or scale them/move them.
I personally thought about this topic when playing around with a fighting game. In that case collision boxes needed to be moved/scaled and triggered at very specific timings as it is the core mechanic of a fighting 1 vs 1 game. (eg.street fighter 2 )
I found a solution for this using Spine animations as you could animate bones and trigger events as you wanted to but there is, what I can see, no good solution for flipbook animations unless you create an inengine editor placing every single collision box for each frame in animation manually and using that data

Thank you for the input @AJirenius! I guess that with Spine it becomes a bit easier. I’d be interested in hearing what @Ragnar_Svensson has to say about the topic?

I agree with @AJirenius, a list of keyed events for flipbook animations seems like the most natural thing. Regarding collisions specifically, scaling the shapes is something that is missing (i.e. “bug”) and which we need to support. That doesn’t solve the most generic case, but it would help.

Is there any update on this feature, or perhaps another recommended solution for having different collision masks during a flipbook animation?

No, nothing has been done on this I’m afraid.