void Update()
{
if (Input.GetKey(KeyCode.Keypad7))
{
ColdGasThrusterServices[0].Left();
ColdGasThrusterServices[2].Left();
}
if (Input.GetKey(KeyCode.Keypad9))
{
ColdGasThrusterServices[0].Right();
ColdGasThrusterServices[2].Right();
}
if (Input.GetKey(KeyCode.Keypad8))
{
ColdGasThrusterServices[0].Down();
ColdGasThrusterServices[2].Up();
}
if (Input.GetKey(KeyCode.Keypad2))
{
ColdGasThrusterServices[0].Up();
ColdGasThrusterServices[2].Down();
}
}
And this is my individual thruster service (has 4 thrusters):
public void Right()
{
ThrusterRight.Play();
RocketRigidBody.AddForceAtPosition(-ThrusterRight.transform.forward, ThrusterRight.transform.position);
}
public void Left()
{
ThrusterLeft.Play();
RocketRigidBody.AddForceAtPosition(-ThrusterLeft.transform.forward, ThrusterLeft.transform.position);
}
public void Up()
{
ThrusterUp.Play();
RocketRigidBody.AddForceAtPosition(-ThrusterUp.transform.forward, ThrusterUp.transform.position);
}
public void Down()
{
ThrusterDown.Play();
RocketRigidBody.AddForceAtPosition(-ThrusterDown.transform.forward, ThrusterDown.transform.position);
}
When i roll my rocket (apparently everything is OK!):
When i pitch my rocket (nothing wrong so far):
Now, look what happens when I try to do Pitch and then Roll:
It’s been many hours that I try to understand what is happening! Can someone help me?
Looks correct to me. When an object gains enough angular velocity around an axis, is quite difficult to make that object rotate around a different axis. Think on a kind of gyroscopic effect.
Both. You’re applying correct forces, and you’re getting the correct effect of those forces.
That’s not a simulation, but a demonstration of the coordinate system. Specifying the rotation rates around specific axes is different than simulating the rotational effects of forces applied to a rigidbody in certain positions and directions.
This is actually a simulation. Summing two rotations (first around Y, second around Z) has the exact same effect you’re observing in your case:
The problem you’re facing is understanding the rotations not as a “compound” of individual rotations, but as an angular momentum as a whole. When you apply a torque (either directly or as a force) you’re adding angular momentum to your rigidbody. Once you stop applying forces/torques the amount of angular momentum remains constant, yet the object may exhibit an apparently chaotic rotation. Typically, the resulting rotation tends to align itself around the axis of smaller inertia.
Understandably, I’ve rarely seen rockets, spacecrafts, satellites, etc executing a rotation around more than an axis a time. They must be very aware of how they are adding or removing angular momentum.
There are other surprising effects of rotations depending on the shape of the body, such as the Dzhanibekov effect: