My GameObject starts out resting on the floor. isKinematic is set to true and a trigger is set to true on the box collider.
When the player touches the collider. It moves the GameObject down below to floor. Then i set the isKinematic to false and the trigger to false. This forces the game object to fall until it hits the floor and stops. My problem is after the game object hits the floor and stops. I can not get the GameObject to recognize it has collided with the floor. I have a Debug.Log statement in OnCollisionEnter2D and OnCollisionStay2D. The Debug.Log does not appear in the console when they touch. Why is this?
The GameObject has a Rigidbody and box collider. The floor has a box collider and Rigidbody as well.
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "Player")
{
Debug.Log ("Player is touching the section");
//sectionRigidbody.isKinematic = true;
if (readyToDrop == false)
//moves player
transform.position += newPosition;
readyToDrop = true;
sectionRigidbody.isKinematic = false;
sectionBoxCollider.isTrigger = false;
sectionRigidbody.collisionDetectionMode = CollisionDetectionMode2D.Continuous;
//sectionRigidbody.isKinematic = true;
}
}
void OnCollisionEnter2D(Collider2D col)
{
if (col.gameObject.tag == "Floor")
{
Debug.Log ("section is touching the floor");
}
}
void OnCollisionStay2D(Collider2D col)
{
if (col.gameObject.tag == "Floor")
{
Debug.Log ("section is touching the floor");
}
}