Turret rotation...
by Matt Van Gorkom · in Torque Game Builder · 03/02/2005 (12:55 pm) · 6 replies
I am once again reminded of my newbieness:
I am attempting to swivel a turret barrel mounted on a turret base. But all the barrel does is twitch while I hold down the key and when I let go it regains its original rotation. What am I doing wrong?
the code:
function player1Up()
{
$turretBarrelPlayer1.setAngularVelocity( 100.0 );
}
function player1UpStop()
{
if ( $turretBarrelPlayer1.getAngularVelocity() != 0.0 )
$turretBarrelPlayer1.setAngularVelocity( 0.0 );
}
I am attempting to swivel a turret barrel mounted on a turret base. But all the barrel does is twitch while I hold down the key and when I let go it regains its original rotation. What am I doing wrong?
the code:
function player1Up()
{
$turretBarrelPlayer1.setAngularVelocity( 100.0 );
}
function player1UpStop()
{
if ( $turretBarrelPlayer1.getAngularVelocity() != 0.0 )
$turretBarrelPlayer1.setAngularVelocity( 0.0 );
}
#2
Is there a way to get what is mounted on an object and change the mounted object's properties?
Something like:
player1Turret.TurretBarrel.setRotation( 90 );
03/02/2005 (1:27 pm)
Hmmm.... I get the same problem with your code. The problem must be elsewhere in my code.Is there a way to get what is mounted on an object and change the mounted object's properties?
Something like:
player1Turret.TurretBarrel.setRotation( 90 );
#3
03/02/2005 (1:47 pm)
You can use track rotation on a mounted object and it will update itself to face the same way as the object it's mounted onto. It's mentioned in the docs, and there was a thread I read here earlier that also mentioned it.
#4
03/02/2005 (1:53 pm)
But no way to rotate an mounted object without rotating the parent unless you reference the mounted object directly as I am doing with my turret barrel in the above code?
#5
would not work:
$turretBarrelPlayer1.mount( $player1, "0 0" );
works now:
$turretBarrelPlayer1.mount( $player1, "0 0", 0, false );
The "false" is turning off whether the mounted object keeps the same rotation as its parent or not. In this case not.
03/02/2005 (2:08 pm)
OK, I finally got my code working. It was a problem with how I was mounting the turret:would not work:
$turretBarrelPlayer1.mount( $player1, "0 0" );
works now:
$turretBarrelPlayer1.mount( $player1, "0 0", 0, false );
The "false" is turning off whether the mounted object keeps the same rotation as its parent or not. In this case not.
#6
- Melv.
03/02/2005 (2:17 pm)
Thanks for posting your solution Matt, that'll help others who may come across the same problem.- Melv.
Torque Owner Philip Mansfield
Default Studio Name
I use similar code to that, and it works fine:
function player1Turn() { $player1.setAngularVelocity( 90 ); } function player1StopTurn() { if ( $player1.getAngularVelocity() != 0 ) { $player1.setAngularVelocity( 0 ); } }