- Home /
How to Change the collider position while playing animation?
Hey Guys! I'm creating a game using the mecanim system. I want to change the y position of my capsule collider attached to the player during the jump animation. How can I do that?
I'm using a curve in my animation called ColliderPosition and I've also created a float parameter in the animator window. I've used the following code with the help of unity mecanim tutorial ofcourse. Just take a look and tell me if i'm doing something wrong.
if(stateInfo.nameHash == jumpState)
{
float colliderPosValue = anim.GetFloat("ColliderPosition");
capsuleCollider.center = new Vector3(0f,colliderPosValue,0f);
}
Please help. ThankYou.
If you are using an animation created with a rigged model in cinema 4d or 3dsmax or... You can simple attach the collider to the bone object and it will always follow it.
hey, it is not working when I am using root motion. The colliders are moving with bone, but it is not colliding with any anything. The collisions are getting ignored on putting the colliders on child objects like the bones.
Your answer
Follow this Question
Related Questions
Editing mecanim animation from script 0 Answers
When jump my character controller model it goes out of collider 0 Answers
Problem using mecanim and the Animation process 0 Answers
Extended Jump Animation Mecanim 0 Answers
Root Motion vs Collider issue. How to stop animation moving char through a collider? 1 Answer