Question by
gangafinti · Oct 28, 2015 at 06:54 PM ·
collision detection
OnCollisionEnter() from non monobehaviour script
I am trying to test if my object collides from a script that doesnt inherit monobehaviour. Since OnCollisionEnter() gets the object the script is attached to it doesnt work inside a normal class that doesnt inherit monobehaviour. Is there anyway to detect collisions from a normal class?
Thank you in advance!
Comment
Answer by Statement · Oct 28, 2015 at 07:35 PM
Make a script that handles OnTriggerEnter and forward the call to your class.
private MyClass myObject = new MyClass();
void OnTriggerEnter(Collider other)
{
myObject.OnTriggerEnter(other);
}
Your answer
Follow this Question
Related Questions
Who calls OnCollisionExit? 3 Answers
How to correctly count number of objects? 2 Answers
OnCollisionEnter2D not calling, but objects are colliding. 1 Answer
Why is OnTriggerExit not firing? 3 Answers
What is ContactPoint.point? 0 Answers