How do I detect a collision between two objects using Bolt?
I've read something about putting "On trigger enter" into one of the objects, but that's it. I don't know how to specify which colliders need to make the event go off. I'm trying to make a clear trigger object for the stage so SOMETHING works in this game I had to make for college.
Answer by PronKill · Jun 08, 2021 at 11:39 AM
If you want to detect a collision between two objects using void OnTriggerEnter, then it would be like this:
void OnTriggerEnter (Collider other)
{
if (other.gameObject.layer == n)
{
Debug.Log("Collided with an object");
}
}
Where "n" is the number of layer which you can see on every object in inspector. For example: Layer named Player will be "6". If Player collided with an object which has the "OnTriggerEnter" script, then console shows "Collided with an object". And make sure that your object has IsTrigger checked in collisions.
Your answer
Follow this Question
Related Questions
Prevent changing speed at collision 0 Answers
Trigger a box collider based on force of an object 1 Answer
OnTriggerEnter not firing 2 Answers
OnTriggerEnter 1 Answer
Problem With Triggers? 0 Answers