Mounting offset problem
by Michael Cozzolino · in Torque Game Engine · 09/08/2005 (8:51 am) · 7 replies
Hi, I thought about this possibly working to have stuff "stick" to players based on collision by using a mount and getting the position of the collision and subtracting the xyz by the xyz of the mount position. The code seems to work as far as getting it to mount and getting the correct values for the offset. Problem is those offset values don't get passed through. It looks like Torque Defaults it to "0 0 0" offset to the mountpoint. Any ideas on how to get around this?
datablock StaticShapeData(Stick)
{
// Mission editor category
category = "Misc";
// Basic Item properties
shapeFile = "~/data/objects/weapons/blaster/bl_ammo.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
};
function BlasterProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
%sticker = %obj.sourceObject;
if(%col.getType() & ($TypeMasks::PlayerObjectType | $TypeMasks::AIPlayerObjectType))
{
%hitx = getWord(%pos,0);
%hity = getWord(%pos,1);
%hitz = getWord(%pos,2);
%mountx = getWord(%col.getSlotTransform(2),0);
%mounty = getWord(%col.getSlotTransform(2),1);
%mountz = getWord(%col.getSlotTransform(2),2);
echo("Mount Pos = "@%hitx - %mountx SPC %hity - %mounty SPC %hitz - %mountz);
%stickPos = %hitx - %mountx SPC %hity - %mounty SPC %hitz - %mountz;
%stick = new StaticShape()
{
offset = %stickPos;
datablock = Stick;
};
MissionCleanup.add(%stick);
%col.mountObject(%stick,2);
}
}About the author
Indie Developer in the Albany NY area. iOS, PC, Mac OSX development. http://itunes.apple.com/us/artist/michael-cozzolino/id367780489
#2
09/08/2005 (10:18 am)
Oops I missed that when editing to post. It is corrected. Still have the problem. :(
#3
Anyone have an idea why
has no effect on the mounting offset?
09/12/2005 (10:03 am)
BumpAnyone have an idea why
offset = %stickPos;
has no effect on the mounting offset?
#4
10/08/2005 (11:32 am)
It will only work if you are using imagedata mounted to the object and not staticshape.
#5
10/09/2005 (6:47 pm)
Thanks Zod I will give it a shot when I get a chance.
#6
10/09/2005 (8:42 pm)
John Kabus has implimented mounted lights in an upcoming version of TLK. I don't know how strongly that relates to what you're trying to do (if objects would be similar to lights), but I'm sure some of the code with mounting (when it comes out) would be put to good use.
#7
07/04/2007 (8:18 pm)
Does anyone know how to change staticshape so it will affect it?
Torque Owner Jason Farmer
I think your problem could be ere
%stick = new StaticShape() { offset = >>>%stick;<<< datablock = Stick; };