Yes the Cube is tagged and my character and the cube have a Character Controller attached to them and they are touching each other but its not printing anything.
Ahem, I tried copying your script and it said to me that I had some spelling wrong(a.k.a. it didn’t have any color in it’s name). So I switch the name of the function and copied the one from the scripting refferences. here’s my result. (If the name doesn’t have any color, or it just doesn’t work, then do as I did)
function OnControllerColliderHit (hit : ControllerColliderHit)
{
print("HEYHEY");
if (hit.gameObject.tag == "cube")
{
print ("hitting cube");
}
}
Ok Ill try using triggers but I dont understand why controller hit is working. Maybe im doing something wrong. Is the script working for you Lime_x?
Are both, the player and the cube have to have Character Controllers or dont you need character controller? and does the player have to be touching the Character controller attached to the cube or does it have to be touching the Cube it self rather than the controller attached to it?
Yes it’s fully functional. the way I posted it.
I didn’t have any rigidbodies on neither of the cubes. I did make sure so that the function was the one from unity. And I also made sure so that the tag was right.
If the tag was wrong and the function worked, then it would print “HEYHEY”. But for me, both the function worked and the tag was right. (the one that I had tagged was the one that didn’t have this script). Have you made sure that the function is the right one(the one copied from the unity link)?
see if i just get two cubes, stick rigid body on “cube”, and on the thing it’s hitting tick “is trigger” in Box collider, then add this script to the ‘thing’ that’s being hit, then the following script works perfectly well:
function OnTriggerEnter (hit)
{
print("HEYHEY");
if (hit.gameObject.tag == "cube")
{
print ("hitting cube");
}
}
Actually I tried your method too Lime, out of interest, and i can’t get what you have working either! So now i’m intrigued.
Ah yes, now I remember. OnControllerColliderHit only works while the cube is moving(so If you don’t have gravity, and it’s standing still on the ground), then it wont move and it wont recognize the hit. I think that might be the problem!