I have a ‘Char’ prefab that has a capsule called BottomCollider as a child…it’s positioned to slightly extend Char’s bottom. I wanted to use it so that whenever your ‘feet’ (BottomCollider, in other words) hit the floor, you can jump again. The jump script is part of Char, and I wanted to set a boolean named jumpValid to True if you touch something with your BottomCollider.
function OnCollisionEnter()
{
var charObj = GameObject.Find("Char");
var charObjJumpScript = charObj.GetComponent(CharJumpFFR);
charObjJumpScript.jumpValid = true;
print("Collision Detected: Under");
}
So, CharJumpFFR is the script that has everything jump-related in it.
For some reason, it doesn’t seem to be doing anything at all. The print doesn’t go off, either. I tried adding a Rigidbody to the cubes that I’m touching with BottomCollider, but it doesn’t do anything. If I add a Rigidbody to BottomCollider, it will do something, though. Everything works fine there.
If I add a Rigidbody AND the script component with OnCollisionEnter() to a cube that I’m stepping on, however, it will work. So I suppose the only one that gets the OnCollisionEnter is the one with the Rigidbody attached? Why, if this section in the Unity reference “Box Collider” says:
When a collision between two Colliders occurs and if at least one of them has a Rigidbody attached, three collision messages are sent out to the objects attached to them.
Shouldn’t both of the involved colliders get these messages sent?
Thanks for any help you could offer!