with out %this how can there be that?
by rennie moffat · in Torque Game Builder · 04/16/2010 (11:36 am) · 9 replies
I have a slight issue,
Essentially what I am trying to do is have an object, collide with another object, upon doing so a 3rd object is placed in position of the %dstObject. So what I want is the dstObject to be remembered, It has to be that specific object tho, as there are many equivalents to it on the board. As such I am unsure as of how to make that work. As in passing info from one to the next.
function cyberTronBehavior::onCollision(%srcObject, %dstObject, %srcRef, %dstRef, %time, %normal, %contacts, %points)
{
///cyberTron Objects
if(%dstObject.class $= "tileClass")
{
if(isObject(%srcObject.tracer1)
{
%srcObject.setTrailer1Pos();
}
}
}
function cyberTronBehavior::setTrailer1Pos(%this, %dstObject)
{
%this.cTTrailer1.setPosition(%dstObject.position);
}Essentially what I am trying to do is have an object, collide with another object, upon doing so a 3rd object is placed in position of the %dstObject. So what I want is the dstObject to be remembered, It has to be that specific object tho, as there are many equivalents to it on the board. As such I am unsure as of how to make that work. As in passing info from one to the next.
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
04/16/2010 (11:46 am)
actually scrap that. I think I need to know more about groups. So sim sets etc. its just to do what I want requires a lot of lines of code.
#3
but anyhow, I hope you get the picture, it got complicated.
anyhow, back to work! This project should be done in the next few weeks, so any one interested, I will keep you posted.
04/16/2010 (11:54 am)
Actually I have just found a real patch solution, but I think simSets and how to make using mass amounts of objects much more flexible as each time I multiplied the number of objects, say enemy 1 test. then it worked so I did enemy 1, 2 and 3 each had there own objects, but anyhow, I hope you get the picture, it got complicated.
anyhow, back to work! This project should be done in the next few weeks, so any one interested, I will keep you posted.
#4
04/16/2010 (12:00 pm)
or maybe I just didn't map it out properly, any how its all in the works. I still need to know the answer to the original question, if that makes sense, please help in pretains to onCollision and the lack of %this, so I think I need how I can better pass object info from a collision. view plainprint?
function cyberTronBehavior::onCollision(%srcObject, %dstObject, %srcRef, %dstRef, %time, %normal, %contacts, %points)
{
///cyberTron Objects
if(%dstObject.class $= "tileClass")
{
if(isObject(%srcObject.tracer1)
{
%srcObject.setTrailer1Pos();
}
}
}
function cyberTronBehavior::setTrailer1Pos(%this, %dstObject)
{
%this.cTTrailer1.setPosition(%dstObject.position);
}
#5
Also in your code above I think your missing a parameter in your setTrailer1Pos() method:
Should probably be:
Just thought that might help some problems you are having.
04/16/2010 (2:08 pm)
%srcObject is the object that just got its onCollision() method triggered. So you can use "%srcObject" as you would "%this".Also in your code above I think your missing a parameter in your setTrailer1Pos() method:
%srcObject.setTrailer1Pos();
Should probably be:
%srcObject.setTrailer1Pos(%dstObject);
Just thought that might help some problems you are having.
#6
thanks.
04/16/2010 (5:27 pm)
yes. ok, i was just trying something "funky" to lighten a load so to speak, I have already gone about it the original way, but ok, the %src is %this essentially helps. thanks.
#7
I understand %srcObject = %this, essentially but what does %dstObject =?
As in
how can I mark that object?
as I have many objects in that class.
04/17/2010 (1:45 pm)
@Kenneth, or anyone else.I understand %srcObject = %this, essentially but what does %dstObject =?
As in
if(%dstObject.class $= "tileClass") %srcObject.doThis();
how can I mark that object?
as I have many objects in that class.
#8
You can use %dstObject in the same way you use %srcObject or "%this".
This is perfectly acceptable code:
04/17/2010 (8:12 pm)
%dstObject is simply the object that has collided with %srcObject.You can use %dstObject in the same way you use %srcObject or "%this".
This is perfectly acceptable code:
if(%dstObject.class $= "tileClass") %srcObject.doThis();
#9
but in
that is my conundrum.
04/17/2010 (8:21 pm)
right, but in
function doThis()
{
///how do I make sure THAT PARTICULAR %dstObject is called, or passed into here?
}that is my conundrum.
Torque Owner rennie moffat
Renman3000