I have a cube and I have a floor. I want an event to happen when the object falls to the ground in a specific position like the one in the picture enter image description here
CodePudding user response:
Get the rotation of the cube in the desired position and save it in a Quaternion. Add colliders to Ground and Cube. One of the colliders should have a Rigidbody. In the OnCollisionEnter function check if the collision is between the ground and the cube and if its true then check if the rotation of the cube is equal to the desired position(with some tolerance). Then add your required code.
CodePudding user response:
Does this help?
private override void OnCollisionEnter()
{
if (this.position == collisionPosition && this.rotation == collisionRotation)
{
// Do Something
}
}