- Home /
Stop sword from distorting character animation
I have a character with a sword as a child of his left hand (parent). I've added a Box Collider and Rigidbody to this sword (Is Trigger, Use Gravity, and Is Kinematic unticked) as I need it to react to collisions and other objects such as enemies.
The problem is that now that my sword has physical elements attached to it, it 'collides' with my character and distorts his running and rolling animations. This doesn't happen when the Box Collider is unchecked, although I can't identify why the Box Collider is doing this as my character has no Box Collider or Rigidbody himself. He does have a Character Controller, however. But yes, the Box Collider on the sword is what's causing the problem.
I have tried to add a Fixed Joint component to my character's left hand, making the sword the property of the Connected Body field - still no luck. Alternatively, perhaps turning off the sword's physics while my character is running/rolling could be a solution, having it turned on only if he swings the sword? I've researched how to do this, but can't seem to get that working either.
Can anyone identify why this is happening and/or provide a solution to the problem?
Many thanks for your time and support in advance.
Answer by AKJ9 · Aug 27, 2014 at 03:09 PM
Done it - assigning each GameObject to a layer and unticking them to cancel their collisions fixed the issue! :-)
Answer by Lando9000 · Aug 27, 2014 at 12:09 PM
try going to the layer collision matrix in Edit->Project Settings->Physics and make the layer go both the character and sword ignore each other (un-tick the correct box).
Answer by Sungatullin · Aug 27, 2014 at 12:09 PM
You can use Physics.IgnoreCollision(collider1, collider2). Arguments of this function are colliders of two objects, which you whant to ignore each other.
But there is other way - collision layers. Read about them here
Your answer
Follow this Question
Related Questions
Why object goes sometimes through walls by adding force ? 2 Answers
Getting a sword in place while attacking an enemy 3 Answers
My Unity Collision Wont Trigger Even with Rigidbody Added 2 Answers
Simple two cube collision is not good? 0 Answers
Objects with colliders going through walls and each other. 3 Answers