I want rigid mounted guns, not HELICOPTER BLADES
by Kevin James · in Torque Game Builder · 06/02/2007 (3:36 pm) · 5 replies
Alright. So in my current project I have a ship that is controlled by the player and that ship rotates to face the mouse. Mounted to the player's ship are two guns and a thruster effect. When the guns and effect are mounted to the ship with Track Rotation as false, they do what you'd expect, they stay at 0 rotation no matter what is happening to the ship.
However, when Track Rotation is true, a very strange phenomenon occurs. The mounts are completely still when the ship is at 0 rotation, but if the ship rotates to the left or right, the mounts start spinning wildly and reach a peak at the 90 and 270 degree mark. They then slow down to not rotating at all at 180 degrees. Keep in mind that the wild spinning is synchronized. It actually looks kind of cool, but it messes everything up!
What I want are mounts that keep the same rotation as the ship, rigidly. I can fudge this with my onTimer callback, but this seems to be an unnecessary accommodation and it is not 100%, there is a slight delay. Why do my mounts spin wildly when Track Rotation is true??
However, when Track Rotation is true, a very strange phenomenon occurs. The mounts are completely still when the ship is at 0 rotation, but if the ship rotates to the left or right, the mounts start spinning wildly and reach a peak at the 90 and 270 degree mark. They then slow down to not rotating at all at 180 degrees. Keep in mind that the wild spinning is synchronized. It actually looks kind of cool, but it messes everything up!
What I want are mounts that keep the same rotation as the ship, rigidly. I can fudge this with my onTimer callback, but this seems to be an unnecessary accommodation and it is not 100%, there is a slight delay. Why do my mounts spin wildly when Track Rotation is true??
About the author
Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/
#2
Yes. As of right now I have an onTimer callback firing every 25 milliseconds on the ship that sets the rotation of the guns and thruster effect to be the same as the ship's rotation.
Yes, I tried this. That is when they spin like crazy: when track rotation is true and they are mounted to the ship. There is one detail I forgot to mention that will probably help you understand the problem. I have an animation for the ship and during it I need to move the guns and thruster effect to accommodate for the new frame of animation. To move these things I "remount" them just with different coordinates. When I take out the line that is for the "idle" animation, the track rotation is fine. I believe that the problem arises because the animations adjustments are located in the onTimer callback of the ship, and thus are being called every 25 milliseconds. What do you think?
06/04/2007 (1:29 pm)
Quote:I read "What I want are mounts that keep the same rotation as the ship" as you are passing the rotation properties of the ship onto the cannons, is this correct?
Yes. As of right now I have an onTimer callback firing every 25 milliseconds on the ship that sets the rotation of the guns and thruster effect to be the same as the ship's rotation.
Quote:Or do you have them mounted static to the ship always pointing forward?
If you want they always to point to the nose of the ship you should have track be true and not be passing anything to the cannons, once they are mounted they will point in the same direction of the ship.
Yes, I tried this. That is when they spin like crazy: when track rotation is true and they are mounted to the ship. There is one detail I forgot to mention that will probably help you understand the problem. I have an animation for the ship and during it I need to move the guns and thruster effect to accommodate for the new frame of animation. To move these things I "remount" them just with different coordinates. When I take out the line that is for the "idle" animation, the track rotation is fine. I believe that the problem arises because the animations adjustments are located in the onTimer callback of the ship, and thus are being called every 25 milliseconds. What do you think?
#3
Heh, not very well explained, once I get home I will post a copy of the code I used. :-)
06/05/2007 (8:24 am)
I believe you are 100% correct because I ran into a similar issue with a tank game I am working on. I wanted the turret to turn with the tank and not just point at its last angle. Because my variable checked only once, when they key was pressed at that exact moment nothing was happening because the turning code was inside the call back function, I had to change my turret code to be part of that call back so it knew that changes were happening and to stop it from turning I added a true or false variable that set the turn velocity to 0 when the turn key was not being held down. And in your case since they do not know when to stop they continue to turn.Heh, not very well explained, once I get home I will post a copy of the code I used. :-)
#4
In my clockwise and counter clock wise turret binding I have this
06/07/2007 (6:42 pm)
Sorry about the delay, but as promised here is my turret code for my tankif ($P1TankTurret.rotate == false)
{
$P1TankTurret.setAngularVelocity( %steerVel );
}I have this tucked away inside the call back function at the very end of it. It checks to see if I am using the turret, if I am not, the turret is turned at the same velocity and angle of %steerVel which is the steering velocity of the turning tank so if the tank is not turning neither is the turret. It gives the illusion that the turret is tracking with the tank.In my clockwise and counter clock wise turret binding I have this
function moveTurretCCW1( %val )
{
if ( %moveTurretCCW1 = %val )
{
$P1TankTurret.setAngularVelocity( -$P1TankTurret.turretTurnSpeed );
$P1TankTurret.rotate = true;
} else {
$P1TankTurret.setAngularVelocity( 0 );
$P1TankTurret.rotate = false;
}
}So if I press the turret button it will stop the callback which is turning it by setting it to true or false. I do not think this second half really helps you, I think all you should need is the first part, add a variable that turns the turrets with the ship.
#5
06/11/2007 (7:51 am)
Hey thanks for the help, Jon. I have everything worked out.
Torque Owner Jon Mitchell
Studio with out a name
If you want they always to point to the nose of the ship you should have track be true and not be passing anything to the cannons, once they are mounted they will point in the same direction of the ship.
If you want them to turn like turrets on their own independent of the ship, it sounds like they are not getting a variable to tell them to stop spinning. Many questions.... It would be helpful for a more detailed description on what you are doing with the cannons.