Arms rotate more quickly than body...
by Matt Van Gorkom · in Torque Game Builder · 09/03/2005 (3:22 pm) · 3 replies
Question: looking down on my character I have his arms mounted 0.65 out away from the main body, when I turn the body I rotate the arms also so that they stay with the body but retain their angle relative to the body... all well and good, but the arms rotate slightly faster than the body and drift.
Is this because the arms are not mounted at the body's origin? If so, is there some way I can figure out what speed relative to the body that the arms need to turn to stay with the body?
I need some way that the child(arm) rotates with the parent(body) unless I tell the child to rotate differently.
Current coding:
Is this because the arms are not mounted at the body's origin? If so, is there some way I can figure out what speed relative to the body that the arms need to turn to stay with the body?
I need some way that the child(arm) rotates with the parent(body) unless I tell the child to rotate differently.
Current coding:
// Right Arm
$player1::rightArm = new fxStaticSprite2D() { scenegraph = t2dscenegraph; };
$player1::rightArm.setGroup($groupPlayer);
$player1::rightArm.setLayer($layerPlayer);
$player1::rightArm.setSize("3 15");
$player1::rightArm.setCollisionActive( false, true );
$player1::rightArm.setCollisionMasks($ColGroupsPlayer, $ColLayersPlayer);
$player1::rightArm.setCollisionPolyCustom( 4, "-1 -1 1 -1 1 -0.75 -1 -0.75" );
$player1::rightArm.setCollisionCallback(true);
$player1::rightArm.setImageMap(KnightRightArmDefaultImageMap);
$player1::rightArm.mount( $player1::shoulderArmor, "0.65 0", 0, false );
function turnPlayer( %player, %playerArm )
{ // left and right
if( %player.turn $= "left" )
{
%player.setAngularVelocity( -%player.spinVel );
if( !%player.swngnPrgss ) // if not swinging then spin arm with player minus vel difference due to arm offset from player?
%playerArm.setAngularVelocity( -%player.spinVel ); // + 2.298029 );
} else if( %player.turn $= "right" )
{
%player.setAngularVelocity( %player.spinVel );
if( !%player.swngnPrgss ) // if not swinging then spin arm with player minus vel difference due to arm offset from player?
%playerArm.setAngularVelocity( %player.spinVel ); // - 2.298029 );
} else if( %player.turn $= "none" )
{
%player.setAngularVelocity( 0 ); // stop turning
if( !%player.swngnPrgss ) // if not swinging then stop arm also
%playerArm.setAngularVelocity( 0 );
}
chooseAnimation(%player);
// if still turning then schedule again
if( %player.turn !$= "none" )
schedule( 50, 0, "turnPlayer", %player, %playerArm ); // make a new schedule
}
#2
09/06/2005 (11:56 pm)
I suspect your mount nodes are not symmetical or not where you think they are. Are you running with debug mode turned on ?t2dSceneGraph.setDebugOn( BIT(1) | BIT(2) | BIT (3) | BIT(4) | BIT(5)); // BIT#0 N/A (Statistics Debug Banner). // BIT#1 Object Bounding/Clipping-Boxes. // BIT#2 Object Mount-Nodes. // BIT#3 Object Mount-Links (force tracking paths). // BIT#4 Object World-Limit. // BIT#5 Object Collision Polygon.
#3
EDIT:
Here's what I'm talking about:
Starting point, the arm is swung backwards. No problem. The mount points are correct. The two extra mount points are where I've placed invisible sprites so collide with the arm so I know where to stop the arm. Messy, but I couldn't figure it out correctly mathematically.

After the player turns six times to the left the arm has swung forward. That's the problem.

After the player turns six more times to the left for a total of twelve turns.
09/07/2005 (6:55 am)
Yes, I am running with debug mode enabled and the mount nodes are where they ought to be. I can't find any reason why the arm would rotate slightly faster than the body. I thought maybe I was damping was the issue but it isn't.EDIT:
Here's what I'm talking about:
Starting point, the arm is swung backwards. No problem. The mount points are correct. The two extra mount points are where I've placed invisible sprites so collide with the arm so I know where to stop the arm. Messy, but I couldn't figure it out correctly mathematically.

After the player turns six times to the left the arm has swung forward. That's the problem.

After the player turns six more times to the left for a total of twelve turns.
Torque Owner Matt Van Gorkom