Game Development Community

SetOrbitMode orientation

by Gary Preston · in Torque Game Engine · 08/29/2005 (9:42 am) · 5 replies

When the player fires a projectile the camera is locked to follow the projectile using

%transform = %obj.getTransform();
  %cl.camera.setOrbitMode(%p, %transform, %min, %max, %start, false);  
  %cl.setControlObject(%cl.camera);

Where %p is the projectile to look at, %obj is the player that fired the projectile and min/max/start are offsets to limit how far away the camera should orbit.

This works with one quirk, the camera is always positioned looking at the object down the +ve X axis as getTransform always returns "1 0 0 0" for the players rotation. So depending upon which direction the player fires, the camera will sometimes be looking at the projectile from behind, in front or either side.

I want the camera to always begin behind the projectile, looking in the same direction as the player who fired the projectile was looking (looking in the direction the projectile is travelling). Anyone able to point me in the right direction for how I should go about this?

#1
08/29/2005 (11:11 am)
Try using the projectiles transform. ie.

%cl.camera.setOrbitMode(%p, %p.getTransform(), %min, %max, %start, false);
#2
08/29/2005 (2:40 pm)
Or even the muzzle point and vector since thats what a projectile starts with also.
#3
08/29/2005 (3:00 pm)
Use getMuzzleTransform() to get it in a form you can use...
#4
08/29/2005 (4:11 pm)
I don't think getMuzzleTransform has a consolemethod set. I guess I could add one, although I've solved it now though based on getMuzzleVector()

%rotz = mAtan( getWord(%obj.getMuzzleVector(%slot),0), getWord(%obj.getMuzzleVector(%slot),1) );               
         %cl.camera.setOrbitMode(%p, %obj.getTransform(), %min, %max, %start, false);
         %cl.camera.setTransform( getWords(%obj.GetTransform(), 0,2) SPC "0 0 1" SPC %rotz );

The problem turned out to be that setOrbitMode was ignoring the initial rotation specified as part of the getTransform(). Calling setTransform on the camera immediately after putting it into orbit mode however seems to work. Whether theres a bug with the setOrbitMode ignoring the rotational element or whether it was never ment to work the way I thought, I've no idea. But the above code works fine, where as


%rotz = mAtan( getWord(%obj.getMuzzleVector(%slot),0), getWord(%obj.getMuzzleVector(%slot),1) );               
         %cl.camera.setOrbitMode(%p,  getWords(%obj.GetTransform(), 0,2) SPC "0 0 1" SPC %rotz,
                                               %min, %max, %start, false);

does not.

If I get chance I'll look into this a little more, as it tends to bug me when I don't understand why something doesn't work, even though I've found an alternative.
#5
02/15/2007 (10:41 am)
Apparently the the Transform part of Setorbitmode is bugged check out this fix

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10297