Finding item position?
by Dracola · in Torque Game Engine · 06/29/2005 (11:03 am) · 14 replies
Can you return an Items position? heres my code.
function mine2::onCollision(%this)
{
%pos = %this.position;
%p = new (projectile)()
{
dataBlock = mineexploder;
initialVelocity = 0;
initialposition = %pos;
client = %this.myclient;
};
MissionCleanup.add(%p);
echo("kabomm");
echo(%pos);
}
the echo for %pos comes up blank and it creates projectiles in random locations. This is the last step to the resource I want to create and its killing me. I've also tried %this.getposition(); and it doesn't like that any help.
function mine2::onCollision(%this)
{
%pos = %this.position;
%p = new (projectile)()
{
dataBlock = mineexploder;
initialVelocity = 0;
initialposition = %pos;
client = %this.myclient;
};
MissionCleanup.add(%p);
echo("kabomm");
echo(%pos);
}
the echo for %pos comes up blank and it creates projectiles in random locations. This is the last step to the resource I want to create and its killing me. I've also tried %this.getposition(); and it doesn't like that any help.
About the author
#2
06/29/2005 (11:06 am)
Don't take me as knowing anything... but i've seen getTransform used to get position before.
#3
06/29/2005 (11:24 am)
Yeah I thought it only worked in C++ but I've also seen it used in earlier scripting and thought it might work. GetTransform might work I think that might be what was used to find spawn points.
#4
06/29/2005 (11:27 am)
Just make a console method that returns getPosition() ... Easy as pie.
#5
06/29/2005 (11:32 am)
I don't have much experience with console commands what exactly would that look like.
#6
you only need to use gettransform() if you need the position and rotation.
06/29/2005 (11:35 am)
%pos=%this.getposition();you only need to use gettransform() if you need the position and rotation.
#7
06/29/2005 (11:36 am)
He said he already tried that. He didn't try getPosition() though.
#8
06/29/2005 (11:47 am)
Actually his original post says he tried getposition() and it "doesnt like that" which is strange because, as far as i know, both methods should work. something else must be wrong.
#9
%pos = %this.getposition();
and got console errors which I could post if anybody wants
06/29/2005 (11:50 am)
I tried this%pos = %this.getposition();
and got console errors which I could post if anybody wants
#10
Just speculating here. Feel free to tell me Im wrong.
Post the errors...
06/29/2005 (11:51 am)
I don;t have code in front of me... but doesnt an onCollision method usually have more hten %this in it ? I thought it had a %obj and %col... Which would allow you to use %obj which is generally the object that is being collided against...Just speculating here. Feel free to tell me Im wrong.
Post the errors...
#11
onCollision(%this, %obj, %col, %vec, %speed)
this is for the player object. i dont believe this is the problem but this would probably make what youre doing alot easier. i just realized something. according to mr. finney, the oncollision function is different for a projectile object:
onCollision(%this, %obj, %col, %fade, %pos, %normal)
I suppose %pos is the point of impact and %normal is the normal of the surface the projectile is incident on, but what is %fade?
06/29/2005 (12:40 pm)
I do =)onCollision(%this, %obj, %col, %vec, %speed)
this is for the player object. i dont believe this is the problem but this would probably make what youre doing alot easier. i just realized something. according to mr. finney, the oncollision function is different for a projectile object:
onCollision(%this, %obj, %col, %fade, %pos, %normal)
I suppose %pos is the point of impact and %normal is the normal of the surface the projectile is incident on, but what is %fade?
#12
mine2::onCollision(%this,%obj,%col)
{
%pos = %obj.getPosition();
..
}
06/29/2005 (1:38 pm)
Try this mine2::onCollision(%this,%obj,%col)
{
%pos = %obj.getPosition();
..
}
#13
06/29/2005 (1:38 pm)
Head about to explode....
#14
06/30/2005 (5:30 pm)
Its working I posted the resource it should come up as soon as they pass it... I hope they pass it.
Torque Owner Chris Labombard
Premium Preferred
EDIT:
Jst a note that getPosition() works in the C++ code... as I used it to do localized precipitation blocks.