I am learning to create a simple fps game in unity the problem is that the collision does not update itself for example initially when my player is on the ground console prints "floor" by "Debug.log(collision.gameObject)" but when it intersects other objects such as a cube console will print out "cube" but when I walk away from it , console does not change back to "floor" Why????
I am using transform.translate to move and jump and using method OnCollisionEnter for collision detection
Remember one thing, the other object you want to collide with need to have a collider component asigned, make sure of it. Join this with the previous answer.
OnCollisionEnter
is triggered only when object enters the collider.A) Make a list of all encountered objects by adding them when
OnCollisionEnter
happens and removing whenOnCollisionExit
happens. Then whenever you need to make sure you are on "floor" check it in the list.B) Use
OnCollisionStay
and every frame you will be notified if you are touching the "floor".I recommend to verify collision. Here on simple example: