Hi there, I have a basic scene with a floor and two objects. Both have rigidBody attached:
In my script, attached to the red cube, I am checking for collisions against the black rectangle.
public class PlayerMovement : MonoBehaviour
{
[SerializeField] private Rigidbody rb;
void FixedUpdate()
{
rb.AddForce(0, 0, 500 * Time.deltaTime);
}
private void OnCollisonEnter(Collision collision) {
Debug.Log("collision detected");
if (collision.gameObject.tag == "Obstacle") {
Debug.Log("Obstacle hit");
}
}
}
Despite stripping the scene down to just the basics you see here, neither the “collision detected” debug log nor the “Obstacle hit” debug log ever gets triggered. If I change to “OnTriggerEnter” and change the rigidBody on the blackbox to “is Trigger”, the debug work. But I want to use OnCollisionEnter. What am I doing wrong that no collision is ever detected? Thank you.
