player rotation
by Sebastiao P. de Almeida · in Torque Game Engine · 01/17/2003 (7:10 am) · 10 replies
Hi all,
I'm playing a little with flying vehicles and I would like to limit the angle of rotation. There is some global variable that holds the player current pitch/yaw/roll and position? Thanx!
I'm playing a little with flying vehicles and I would like to limit the angle of rotation. There is some global variable that holds the player current pitch/yaw/roll and position? Thanx!
#2
01/17/2003 (8:45 am)
I've already tinkered with it but it ins't what I need. I want the ship to turn fast but not roll more than 90 degrees. And I would like to restrict the vertical movement too so the player couldn't "loop".
#3
01/17/2003 (9:49 am)
Oh, I have a feeling that you're going to have to code that in the engine. =/
#4
01/17/2003 (9:55 am)
Yeah, I thought I would. Thanx anyway!
#5
you can try adding something like this:
in FlyingVehicle.cc... try adding it before this:
what this does is limit the rotation in the vehicle's y axis. The rotation goes from -1 to 1 (i think).
AS well, for the x axis (pitch), you can add this:
That code should be added to the updateForces method btw...
[/edit]
Mike
01/17/2003 (10:34 am)
Hey,you can try adding something like this:
//Make sure we can't go inverted
if(mRigid.state.angPosition.y > 0.4f){
mRigid.state.angPosition.y = 0.4f;
}
else if(mRigid.state.angPosition.y < -0.4f){
mRigid.state.angPosition.y = -0.4f;
}in FlyingVehicle.cc... try adding it before this:
//Apply the forces to the rigid body mRigid.state.torque = torque; mRigid.state.force = force;
what this does is limit the rotation in the vehicle's y axis. The rotation goes from -1 to 1 (i think).
AS well, for the x axis (pitch), you can add this:
//Limit the rotation in the x axis as well (pitch)
if(mRigid.state.angPosition.x > 0.35f){
mRigid.state.angPosition.x = 0.35f;
}
else if(mRigid.state.angPosition.x < -0.35f){
mRigid.state.angPosition.x = -0.35f;
}[edit]That code should be added to the updateForces method btw...
[/edit]
Mike
#6
01/17/2003 (12:34 pm)
It will need some fine tuning but, basically, this solved my problem. Thanx buddy!
#8
01/19/2003 (1:52 am)
tilt is in there too, i forget the name but you can set the roll factor to.
#9
01/20/2003 (10:40 am)
Sorry, but I didn't understand your last post. You could set the roll to what?
#10
01/22/2003 (2:53 am)
I've noticed a problem with the above solution, when the ship is near the limit, it slows down until it stops. I wonder if there is some solution that doesn't require messing with the physics.
Torque Owner Kirby Webber
I'd play with this value to get the "feel" you want.
*hope this helps*