-1
\$\begingroup\$

I have an object with a rigid body. How would I go around detecting collisions between this object and any other object with a collider on it?

I know you can enable/disable collision detection (https://docs.unity3d.com/ScriptReference/Rigidbody-detectCollisions.html). Is there an event that gets fired whenever an object collides?

My Rigidbody object:

Bullet

A typical object that it would collide with:

Plane

Extra info: This is Unity 3D, with version 2019.4.8f1o on the Universal Render Pipeline

\$\endgroup\$
0
\$\begingroup\$

Is there an event that gets fired whenever an object collides?

OnCollisionEnter

//Automatically fired when a collision occurs
void OnCollisionEnter(Collision collision) {

}

This is something you could easily have found with a web search.

\$\endgroup\$
  • \$\begingroup\$ I don't know how, I don't know why, but for some reason, I wrote this down to prove you wrong, because I have tested this in the past and it didn't work. I do not know what you did, but thank you. I have no idea how it suddenly works, but I am actually amazed. Thanks. \$\endgroup\$ – OskarZyg_old Aug 16 '20 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.