How do I use the Collision Node?

How do I get the collision event to fire when an object collides with another specific object?
image

I assume I want to connect something to the “Collision” circle, but I’m not sure what.

I think the collision value here can be used to get data about the collision itself. See below for a C# example of how collision is used.

https://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html

void OnCollisionEnter(Collision collision)
{
    foreach (ContactPoint contact in collision.contacts)
    {
        Debug.DrawRay(contact.point, contact.normal, Color.white);
    }
}

More info on the collision class - https://docs.unity3d.com/ScriptReference/Collision.html

Hmmm… so looking at the unity docs, it seems like OnCollisionEnter is not the even I want to use at all. In Q’s BallAndGoalExample, he uses OnTriggerEnter instead.

I’m still not sure how to set it up to detect collision with a specific object, though.

You should just be able to get the collider from the collision event and branch on whether the collider is attached to the object you want.
Actually detecting a given object can be done with a hard public reference, or by gameobject name, or using layers, or using tags (if we get tags working)

This should work:


That’ll rotate any object that collides. You can compare it with the methods Cubed described to limit.

(edit: hooked up the event)