- Home /
Collision not working
Hello, im new to unity and I have a problem with collision with my player and terrain. The player just goed through the terrain! I added a box collider to my main character, and the trigger option is unchecked on both I also used a script that checks is collision working but it does not say anything in the debug log. I tried to attach a rigidbody to my character but then I cant controll my player normaly. Does anyone know what is wrong?
function OnCollisionEnter(collision:Collision){
if (collision.gameObject.tag == "Char")
{
print ("yay");
}
}
Thank you for your help
Answer by Alec-Slayden · Mar 05, 2012 at 09:48 PM
Collision signals require a rigidbody on at least one of the objects. If you're not already, you should probably use a Character Controller object (should come with one of the importable unity packages if not loaded by default).
With the character controller, use
The character controller comes with movement, jumping, and a few tweakable settings to provide a smooth and intuitive movement.
if you can't use a character controller, you'll need a rigidbody to get a CollisionEnter. It might help to adjust the gravity, restrictions, or drag in the inspector.
Your answer
Follow this Question
Related Questions
3D box collider go through terrain 1 Answer
Player keeps falling halfway through terrain floor 3 Answers
character bounces on a box 0 Answers
Internal collisions 1 Answer
tire falling through terrain? 1 Answer