Positioning Question
by Nathaniel Plane · in Torque Game Engine · 09/01/2007 (7:30 pm) · 0 replies
Hi all,
I'm trying to accomplish what is a seemingly simple task of locating a position ahead of the player X units, while taking into consideration the player's view angle. I've been able to get something pretty close by hacking together a simple calculation of the muzzle vector's Z value.. but it's not perfect (point's z position is often too extreme, ie too high at high angles, too low at low angles).. And honestly, this approach just seems too dirty, but with the (seemingly) limited math functional in torquescript this is the best i could do in an hour or so.. Any help would be greatly apreciated, im sure im missing SOMETHING, SOMEWHERE =)
%amount = 5;
%zAngle = getWord(%obj.getMuzzleVector(%slot), 2);
%z = %amount * %zAngle;
%y = %amount - (%z >= 0 ? %z : -%z);
%point = "0" SPC %y SPC %z;
%trans = %obj.getTranslation();
%point = MatrixMulPoint(%trans, %point);
I'm trying to accomplish what is a seemingly simple task of locating a position ahead of the player X units, while taking into consideration the player's view angle. I've been able to get something pretty close by hacking together a simple calculation of the muzzle vector's Z value.. but it's not perfect (point's z position is often too extreme, ie too high at high angles, too low at low angles).. And honestly, this approach just seems too dirty, but with the (seemingly) limited math functional in torquescript this is the best i could do in an hour or so.. Any help would be greatly apreciated, im sure im missing SOMETHING, SOMEWHERE =)
%amount = 5;
%zAngle = getWord(%obj.getMuzzleVector(%slot), 2);
%z = %amount * %zAngle;
%y = %amount - (%z >= 0 ? %z : -%z);
%point = "0" SPC %y SPC %z;
%trans = %obj.getTranslation();
%point = MatrixMulPoint(%trans, %point);
About the author