- Home /
How can I dynamically change colliders when animating a 2d sprite?
I have a very simple attack animation that basically extends the size of the sprite default sprite collider, and I want to detect that the attack actually hits something.
In a normal state, the sprite would have a very simple circle collider
but when attacking, it would look something like this
All the sprites in the sheet are of same size, it's just the "colored" area that becomes larger.
What I'm looking for is a way to detect collisions with this expanded area. Should I manually create the collider by hand and disable it in place of the animation, and then re-enable it once the animation has started?
I can see that working in a simple case, but what if the sprite changes a lot? Even if I cropped all the sprites in the sheet to the minimum possible size (which I'm not sure I should do, instead of using a grid slice?), I still wouldn't really be able to add a collider based on the shape, right?
Is there some way to have a collider adjust to a shape? How do people do this when the animations have a lot of moving parts and they get complicated in terms of collisions?
Your answer
Follow this Question
Related Questions
Click an object to applyforce in different directions. 1 Answer
Sprites automatically become smaller 0 Answers
Physics2D.BoxCastAll not registering hits 0 Answers
A tricky problem with Particle Collisions 0 Answers
How do I use SpriteManager? 1 Answer