- Home /
Sphere collider going through character controller. Please help.
Hi everyone
I am making a game in which a sphere with a sphere collider is moving towards the character which has a character controller component added to it. The character is in mid air and has a script which uses the function OnControllerColliderHit and is meant to change scenes when the sphere hits the character. If the character is moving when the sphere hits it this works perfectly. When the character is stationery, however, the sphere goes right through it.
Any help would be greatly appreciated.
Thanks.
Does your sphere have a rigidbody attatched? $$anonymous$$oving objects need a rigidbody (or a character controller).
Also, have you have to move them physically - you can't change the transform directly, or it's non-physical movement.
Answer by ls · Feb 05, 2013 at 12:06 AM
Hi everyone
Thanks for the replies. I'm 16 and only just got Unity recently so it's all a steep learning curve for me. I think, thanks to your help, that I've managed to fix it. I took the character controller off entirely and added a rigidbody to the character and unchecked gravity. Instead of using the OnControllerHit function I now use the OnCollisionStay function. I also added a kinematic rigidbody to the sphere with no gravity and that seems to have done the trick.
Thanks :)
You may want to choose your own answer as the "correct" answer. This essentially "closes" this question. When the person who asks the question chooses a "correct" answer, the badge goes green and people will not try to add a new answer.
You might also want to look into this: http://unity3d.com/company/support/online-training/
Don't forget you can register on the day, even when the classes say "full".
Your answer
Follow this Question
Related Questions
Jump Animation questiom 0 Answers
Character Controller won't collide with anything 1 Answer
Character Controller vs moving platform 0 Answers
Character Controller problems with a space ship 1 Answer
Scripting a Player Character Collider 0 Answers