- Home /
How to update 2d colliders with spirte animation ?
Hi, I have attached a 2d collider to my game object, but when animation is playing the collider is not updating, can anyone tell me how to update collider with the animation? Thanks
Answer by thor348k · Jun 22, 2016 at 05:08 AM
By your question, I assume you already know how to make an animation, and add it to a controller.
When editing the animation, or when you're adding frames, you should notice the record button is selected. While this is set, you can change other properties for the controller's object. Which means, you can adjust the collider size to fit, at each frame.
Colliders don't automatically adjust to fit the individual sprite frames.
Hope this helps! :)
Do you know how you do that? Because when I try to add a collider property to my animation, I can only choose between "Enabled", "IsTriggerd" and stuff like that. I don't see how I can change the collider somewehere. Would be great to get an answer, I really need it!
Hi thanks for your response, I've done exactly as you said, but when I edit the collider to match the current sprite, it changes the collider to that for all the sprites (overwrites all other collider changes). I'm not sure what I'm doing wrong, any response would be appreciated!
Wrong answer, you can't record changes in colliders such as Polygon Collider 2D :/
Answer by shieldgenerator7 · Nov 13, 2017 at 07:54 PM
You have to add a Collider2D to the GameObject (such as BoxCollider2D), and then on the animation pane, click the record button. Then for each frame you want to change the collider, click the "Edit Collider" button on the collider's component in the Inspector pane, and adjust it to what you need.
The animation has no "collider" propety. The collider is a component on the GameObject that has the Animator.
Answer by Solitari · Jul 19, 2020 at 03:53 AM
I didn’t imagine that unity had this problem, it’s not possible to make fluid animation, because the box collider, a capsule collider or other doesn’t follow the animation, and if you do step by step, you never record properly, and when you record, you record for others animations
Answer by awsapps · Oct 19, 2021 at 11:02 AM
Set up as many child objects as different colliders you have, for each one, place the collider to fit the animation. While animating, active the corresponding child object...