Collision and trigers
by Bojan Vukojevic · in Torque Game Builder · 07/22/2010 (5:25 pm) · 2 replies
Hello all,
I have a problem that i think is pretty simple but i just cant see the solution I would appreciate any help. I have created an object that has collision callback on and receive collision on but send collision is disabled. There is a trigger mounted on that object. When i start the project function for objects collision ie in its namespace gets called and object is the sender. Here is the example code:
What i get in the console is:
I get this many times per second. I know how to test who is sending the collision and just ignore this but i would like to disable this because may have a lot of objects similar to this and I'm afraid it would be a performance problem in the future. Also send collision is disabled on mainObject how can it be the @srcObject.
While on the subject can someone please explain the situation with triggers and its send/receive collision. I read something and apparently you cannot disable its collision events. I believe this is because onEnter, onLeave and onStay are some kind of collisions just wanted to confirm it.
Thanks
I have a problem that i think is pretty simple but i just cant see the solution I would appreciate any help. I have created an object that has collision callback on and receive collision on but send collision is disabled. There is a trigger mounted on that object. When i start the project function for objects collision ie in its namespace gets called and object is the sender. Here is the example code:
function prepareScene()
{
%mainObject=new t2dStaticSprite()
{
scenegraph = sceneWindow2D.getSceneGraph();
imageMap = "playerImageMap";
position = "0 0";
class="mainObjectClass";
CollisionActiveSend = "0";
CollisionActiveReceive = "1";
CollisionCallback = "1";
};
%mainObjectTrigger=new t2dTrigger(%mainObject.GetPosition())
{
scenegraph = sceneWindow2D.getSceneGraph();
size = "35.000 35.000";
class="mainObjectTrigger";
CollisionDetectionMode = "CIRCLE";
};
%mainObjectTrigger.mount(%mainObject);
}
function mainObjectClass::onCollision(%srcObject, %dstObject, %srcRef, %dstRef, %time, %normal, %contacts, %points)
{
echo(%srcObject.getClassNamespace() @ " Hits " @ %dstObject.getClassNamespace());
}What i get in the console is:
mainObjectClass Hits mainObjectTrigger mainObjectClass Hits mainObjectTrigger mainObjectClass Hits mainObjectTrigger mainObjectClass Hits mainObjectTrigger
I get this many times per second. I know how to test who is sending the collision and just ignore this but i would like to disable this because may have a lot of objects similar to this and I'm afraid it would be a performance problem in the future. Also send collision is disabled on mainObject how can it be the @srcObject.
While on the subject can someone please explain the situation with triggers and its send/receive collision. I read something and apparently you cannot disable its collision events. I believe this is because onEnter, onLeave and onStay are some kind of collisions just wanted to confirm it.
Thanks
#2
The thing that confuses me is why is mainObjectClass (from my example) source of the collision when his sendCollision is false? I was expecting that the response would be something like "mainObjectTrigger Hits mainObjectClass" not other way around.
For the triggers: if i disable send and receive collisions on a trigger will it still work? And is it possible to disable it at all?
I found the document very useful and i would love to read something similar but for physics. Do you know maybe if there such a document?
07/23/2010 (11:16 am)
Thanks for the info William. I've read the whole document and, although i did find a lot of useful information, i did not find the answer to my problem.The thing that confuses me is why is mainObjectClass (from my example) source of the collision when his sendCollision is false? I was expecting that the response would be something like "mainObjectTrigger Hits mainObjectClass" not other way around.
For the triggers: if i disable send and receive collisions on a trigger will it still work? And is it possible to disable it at all?
I found the document very useful and i would love to read something similar but for physics. Do you know maybe if there such a document?
Associate William Lee Sims
Machine Code Games
tdn.garagegames.com/wiki/images/a/a3/Collision_Detection_and_Response_Rev2.pdf
They way you have it now, the object can receive collisions and will get a callback for it.
Triggers can be thought of as "pressure pads". When you step onto them, you'll get an "onEnter". While you are still there, you'll get an "onStay". And, obviously, when you step off, you get an "onLeave".