Offsets and rotated objects
by baylor wetzel · in Torque Game Builder · 11/28/2007 (1:19 pm) · 3 replies
My ShootingBehavior lets an object show a muzzle flash. Since it would look silly in the center of the person, i let them specify an offset
If offset="0 -8", the muzzle flash goes in front of the unit (if he's facing up) but if the guy turns sideways, he gets a muzzle flash coming out of his shoulder
Is there a way to find out where the equivalent of "0 -8" is on a rotated sprite?
There are hack arounds. i could mount it, but it requires the sprite owner to build me a mount and prevents that sprite from mounting anything else at runtime (since mount() doesn't allow you to specify the link point). i could make the muzzle flash the same size as the sprite and then just rotate it, but that's a pretty strict limitation to put on the user of the behavior. i could make different imagemaps (guyFiringImageMap) and swap them at runtime but that is pretty resource intensive (resource=my time). So i'm hoping there's a rotated or invariant local coordinate system that i can use
If offset="0 -8", the muzzle flash goes in front of the unit (if he's facing up) but if the guy turns sideways, he gets a muzzle flash coming out of his shoulder
Is there a way to find out where the equivalent of "0 -8" is on a rotated sprite?
There are hack arounds. i could mount it, but it requires the sprite owner to build me a mount and prevents that sprite from mounting anything else at runtime (since mount() doesn't allow you to specify the link point). i could make the muzzle flash the same size as the sprite and then just rotate it, but that's a pretty strict limitation to put on the user of the behavior. i could make different imagemaps (guyFiringImageMap) and swap them at runtime but that is pretty resource intensive (resource=my time). So i'm hoping there's a rotated or invariant local coordinate system that i can use
About the author
#2
In my case, it doesn't really help because the Behavior wouldn't know which link point to use. Unless, i suppose, the user passed that in as a parm. Hmm...
11/28/2007 (3:50 pm)
I've asked this before about older versions and to the best of my knowledge, you can't specify a link point. The mount command didn't accept link point as a parameter. Is there a new version of mount that let's you choose a link point at run time?In my case, it doesn't really help because the Behavior wouldn't know which link point to use. Unless, i suppose, the user passed that in as a parm. Hmm...
#3
12/12/2007 (1:23 pm)
Not really necessary to mount it. If you know the linkpoint number, you can use getLinkPoint(n), which returns the world-position of a given linkpoint. Or you could do something like this:function t2dSceneObject::getRelativeOffset(%this, %offset)
{
// Get the offset in local space that corresponds to the offset in world space.
// NOTE: Not the same as getLocalPoint
%offX = 2 * getWord(%offset,0) / %this.getSizeX();
%offY = 2 * getWord(%offset,1) / %this.getSizeY();
// Return the actual world position (takes rotation into account)
return %this.getWorldPoint(%offX, %offY);
}
Associate Phillip O'Shea
Violent Tulip