What you want maybe is a OnControllerColliderHit() on your player script. Collision with non rigidbody objects is always wierd.
Unity Docs link : file://localhost/Applications/Unity/Unity.app/Contents/Documentation/Documentation/ScriptReference/CharacterController.html
(might not work)
As far as i know, a rigid body collision works perfectly, when the rigid body moves at speeds equal or below is its own z-dimenson per frame.
So, for example a rigid body with z = 1 meter should not move more than 1 meter per frame. If you have rigid bodies moving faster you can decrease the time step in the physics setting to keep collisons acurate.
What is the best way to script an object so it knows that a charactercontroller has come into contact with it?
I know I can capture collisions within the charactercontroller (CC) itself via “OnControllerColliderHit” but that’s somewhat limiting as there doesn’t seem to be a companion function to tell me when the CC has stopped touching something. This is needed so I can know when, for example, the player has stepped off of a lift.
It feels like the CC is a cool concept and makes the basics very easy, but it is fairly limited when it comes to physical interactions with the world (i.e. collisions and notifications of such). Is this a fair assessment?
What I meant was objects without rigidbodies should not be relied on to get collision messages. In this case a script that checks if the player is inside a child trigger.
if(myTrigger.bounds.Contains(player.trasform.position))
{
print("player on lift");
}
Thanks Yoggy. I’ve set it up now with a trigger attached to the top of the lift so I get proper notifications of the players comings and goings. It isn’t ideal (I strive for utmost simplicity when I can get it) but it’ll work.