- Home /
Why collidion doesn't work on a cube attached to first person controller
Hello, I have placed first person controller and attached a cube to it. Than I have created another cube on the ground without rigidbody but with box collider and the cubes doesn't collide with any other object. How can I repair that? Thank you
Answer by Omar47i · May 25, 2014 at 06:34 PM
So u want to detect collision between Character Controller attached to A first person controller prefab and a Box Collider attached to a box, if that is the case u should examine collision on any script attache dto the player in the callback Message:
function OnControllerColliderHit (hit : ControllerColliderHit)
{
// hit is the thing that we are colliding with
}
It doesn't do anything.
function OnControllerColliderHit (hit : ControllerColliderHit) { if(hit.gameObject.name == "clear_gold") { type = 8; audio.PlayOneShot(audio1); } }
will, actually the first person controller prefab that come with unity in the standard assets cannot just walk through any game object that has a collider attached, just try to follow these instructions maybe u mess somting:
insure that u don't miss type the game object name u r colliding with "clear_gold".
the script that has this function "OnControllerColliderHit()" is attached to the parent gameObject that has the Character Controller Component (which in this case the First Person Controller parent object).
insure that the object u test collision with has a collider.
try this and tell me if it solves ur problem, ahh forgot to mention if the object u r colliding with has the property "Is Trigger" checked ?
Your answer
Follow this Question
Related Questions
Simple OnGui does not work 1 Answer
Simple Object Pick-Up 2 Answers
Joystick.cs Invisible 1 Answer
Glitching between box colliders. One is kinematic... Help! 1 Answer
Problem with Simple Script - Rotation and Data Types 1 Answer