Game Development Community

Overriding onCollision in script for a class object

by Rob Segal · in Torque Game Builder · 07/12/2006 (12:07 am) · 8 replies

If I declare a class object as follows....

%myObj = new ScriptObject()
{
  class = "MyClass";
};

I know I've seen somewhere you can override the onCollision method for all objects of this particular class. Something like...

function MyClass::onCollision(...)
{
}

But I'm not sure of the parameters here hence the ellipses. Would I be correct that you can do this and if so what are the parameters I'm missing here?

#1
07/12/2006 (1:44 am)
Hey Rob,

function MyClass::onCollision(%srcObject, %dstObject, %srcRef, %dstRef, %time, %normal, 
%contacts, %points)

This works, though your object needs to be registered to receive a callback on collision. Check the docs for a description of the parameters.

Chris

[edit] Not sure if this works on ScriptObjects - just t2dSceneObjects and its subclasses. [/edit]
#2
07/12/2006 (2:58 am)
That's correct, ScriptObjects don't have collision. They don't even have position or rotation.
#3
07/12/2006 (5:33 am)
Great thanks Chris I will try that out.
#4
07/12/2006 (5:41 am)
Great thanks Chris I will try that out.
#5
07/12/2006 (6:46 am)
Thomas, that's wrong... ScriptObjects do have collisions. I'm using ScriptObjects as invisible obstacles in my game.
#6
07/12/2006 (7:11 am)
@Oliver - Are you sure you don't mean t2dSceneObjects? I might have missed something though...
#7
07/12/2006 (7:13 am)
Oh yeah, sorry, my bad! Still too early in the morning. ;)
#8
07/12/2006 (8:03 pm)
You had me confused for a sec.. ;)