Collisions
This page is for detecting collisions between non-triggers, to detect collision with triggers go to https://wiki.facepunch.com/sbox/Triggers
Detecting Collisions
To detect when an object touches, or stops touching another, both GameObjects must have a collider component attached(box, sphere, etc), with the Is Trigger
box unchecked on both of them.
For a component to detect triggers, it must be on the same GameObject
as one of the collider components.
First inherit from Component, Component.ICollisionListener
, then implement public void OnCollisionStart()
or public void OnCollisionStop
, public void
is necessary. In the parenthesis, add Collision collision
. This sets a variable "collision" to the collision event so you can use it in code.