Author Topic: Get Horizontal Rotation of a Transform  (Read 1163 times)

I need to get the, I think, Z rotation of an object so I can rotate the player precisely on the relative X axis. Basically I want to get the left, right rotation specifically, so I can face the player down based on that instead of where the player currently is, rotation and all. %obj.getPosition(); works but it doesn't include the left, right rotation.

You cannot face the player down.

I need to get the, I think, Z rotation

http://forum.blockland.us/index.php?topic=27230

%eulerRot = axisToEuler(getWords(%obj.getTransform(),3,6));

%xrot = getWord( %eulerRot, 0 );
%yrot = getWord( %eulerRot, 1 );
%zrot = getWord( %eulerRot, 0 );

Code: [Select]
%eulerRotation = axisToEuler(getWords((%obj.pj.getTransform()),3,6));
%tilt = "-30 0 0";
%obj.pj.setTransform(getWord(%eulerRotation,2) SPC eulerToAxis(vectorAdd(%tilt,%eulerRotation)));
Makes the player get deformed.

Code: [Select]
function Player::doFlip6(%obj)
{
%pos = %obj.getPosition();
%eulerRotation = axisToEuler(getWords((%obj.getTransform()),3,6));
%tilt = "-30 0 0";
%z = getWord(%eulerRotation,2);
%obj.pj.setTransform(vectorAdd(%pos,%z) SPC eulerToAxis(vectorAdd(%tilt,%eulerRotation)));
}
This doesn't deform the player anymore but you still do random rotations instead of a solid X one.

Code: [Select]
function Player::doFlip6(%obj)
{
%pos = %obj.getPosition();
%eulerRotation = axisToEuler(getWords((%obj.getTransform()),3,6));
%tilt = "-30 0 0";
%obj.pj.setTransform(%pos SPC eulerToAxis(vectorAdd(%tilt,%eulerRotation)));
}
Rotates the player -30 degrees on the X axis (assuming the player is mounted to %obj.pj and that object can be rotated)

Rotates the player -30 degrees on the X axis (assuming the player is mounted to %obj.pj and that object can be rotated)
Get on Bl, I'll show you what happens.