- Home /
Charcontroller doesnt collide when not moving
Thanks everyone! So, here is the situation:
From testing multiple ways, i seem to have arrived to this conclusion:
Box, capsule, sphere etc collider: Does collide with any other object when not moving, However, When i make a script to get it moving as a character (translate, position = new position xyz) it always ends up pushing through other colliders and walls after a few seconds of making my character walk into them (we dont want our main character to just walk through chairs and walls do we?)
Character Controller: Only Collides when using the .move function, and NEVER goes through other colliders or walls, BUT, things will just go right through it when it is not under the move function in that frame.
So say i have 2 Character controller on my characters, and have one of them attack the other with a sword (the sword either has a box collider or a char controller) If the attacked character isnt moving, the sword just goes right through without triggering the collision.
How would I manage to get the sword to collide with the character controller when the character controller is NOT moving? Is there some hidden function i dont know about the character controller?
If impossible, what is the best way to get a sword to interact with a character wich either has a box collider or a character controller?
Thank you again to anyone who can help me!
How are you moving the sword? The sword will have to do the collision checking in this case, as it is the moving body.
The sword is moved by the animation of attack of the character. If the sword has either box or char controller, and the opponent has his char just staying idle, the sword goes through the opponent and does not trigger colision (either side) (opponent would have a char controller too in this situation)
As stated earlier, the box will have to be the object doing the collision checking. It therefore needs a rigidbody and your animation has to have "animate physics" enabled.
Thank you, i will look into that and set this question as answered!
Answer by Benproductions1 · Dec 22, 2013 at 12:05 AM
Hello,
In for optimisation purposes Unity only does one way collision checking. A non-moving rigidbody or character controller will not check for collision with bodes that move towards it. Instead that moving object will have to do the collision checking.
For a object that is being animated to do proper collision checking two things need to happen:
Like with most other collision checking the object needs to have a rigidbody attached. Because it will be animated there is no need for it to do any physics by itself so having it be Kinematic is an added optimisation.
For the animation to work properly in cooperation with collision detection the animator needs to emulate velocity from movement due to the animation. For this to happen you just need to enable the "animate Physics" option.
Now your collision detection should work on the sword.
Hope this helps,
Benproductions1
Thank you very much for all your help sir! $$anonymous$$UCH apreciated!
Your answer
Follow this Question
Related Questions
My Character Controller is falling through... everything... 4 Answers
My Character Controller Is Warping Randomly (/w video) 0 Answers
how to correctly check for a collision with a character controller 1 Answer
Terrain, Player falls through.... but only some parts. 0 Answers
Character Controller collision disabled after some time 0 Answers