Rukey4
1
Hello,
I’ve searched and searched for an answer but I have not found a solution, maybe it’s pretty simple. Heres my problem.
I have a cube, with the box collider and rigidbody and an FPSController tagged “Player”.
Here is the script I have attached to my cube:
function OnCollisionEnter (other : Collision)
{
if (other.gameObject.tag == "Player")
{
Debug.Log("I'm Here!");
}
}
OnCollisionEnter works a little differently when one of the colliding objects has a character controller on it. It will fire when an object with a rigidbody hits the character controller, but not the other way around. Take a look at OnControllerColliderHit and see if you have any luck with it.
I’ve had this problem before, and although this may not be the correct answer, I hope I can help. I assume you are using a rigidbody on the Character Controller, and you are calling it a “gameObject”. Instead:
herefunction OnCollisionEnter (other : Collision)
{
if (other.rigidbody.tag == "Player")
{
Debug.Log("I'm Here!");
}
}
Rukey4
4
I’ve answered my own question. I used:
function OnControllerColliderHit (hit : ControllerColliderHit)
{
if (hit.gameObject.tag == "Platform")
{
Debug.Log("I'm Here!");
}
}
Adding this to my FPSController.