- Home /
Equivalent to this using torque
transform.Rotate(Vector3.right * Time.deltaTime*100, Space.World);
transform.Rotate(Vector3.forward * Time.deltaTime*360, Space.Self);
So, what I wonder is if there's a way of creating the results gained with this bit of code when using AddTorque(), AddRelativeTorque(), a combination of both or any other physics-based solution. The result here is an object rotating around two separate axes. My tests using different forms of torque has so far only given me an object rotating around a single axis; Vector3(1,0,1) which is nowhere near my desired results.
Does Unity simply combine axes when using torque or have I, as I hope, made mistakes in my tests?
I've thought about that but the parent always has the rigidbody and as such controls the whole hierarchy downwards, right? So adding something above the current parent just forces me to move the rigidbody and then nothing really changes. Thanks for your help though.
The problem is that I want to rotate an object around two different vectors. By adding torque around two different axes in Unity you'd think that's what you'd get but it ins$$anonymous$$d you get a rotation around a single vector between those two.
I'm working on a realistic skate-game using only forces to create the tricks. A kickflip, the trick currently bugging me, comprises of pushing the nose of the board down a bit to level it out during which the board spins 360 degrees around it's forward axis. To simulate this I want a low torque around the board's right axis(Compensated so it doesn't move when the the second rotation's added.) to tip it forwards so it's level with the ground and also a higher torque around the boards actual forward axis to do the actual trick. What I ins$$anonymous$$d get is a single rotation that goes around an axis between the forward and right ones.
If you've got time you could try adding the two lines of code above to a rectangular object with an attached rigidbody not using gravity. That's the basic effect that I'm after. Try getting that result using only forces applied to the rigidbody and you'll either see the problem or a solution.
Answer by Bunny83 · Jul 04, 2012 at 10:21 PM
That can't work ;) You always have a rotation around one axis. With forces the momentum is building up slowly. What you want would result in strange forces that change the direction very quickly. All physics parameters(velocity, angularVelocity) are always calculated in worldspace. If you add a force or torque in local space, it's just converted into worldspace.
Momentum doesn't like a changes of velocity. You always need the same amount of force to stop a motion that was needed to create it. Rotationaxis can't be simply rotated. It's the same as a spinning top.
So to answer your last question, yes, the angular momentum is always around one axis.
edit(Oct 2017)
I just realised that Unity's physics simulation does not follow Newton's first law. The main issue here is that without external forces / torques the linear momentum as well as the angular momentum stays constant. However this migh lead to confusion because linear momentum is not the same as linear velocity. Though the only difference here is that the linear momentum is simply the linear velocity multiplied by the mass. Since the mass is constant we can simply ignore this difference because if the velocity stays constant the linear momentum will also be constant.
However here's the problem when it comes to angular momentum and angular velocity. The relation is similar but instead of the mass of the object we have to deal with the objects inertia. Unlike the mass the inertia of an object depends on the axis of rotation. That means the inertia can actually change while the object rotates. If the angular velocity stays constant (that is what Unity does) the actual angular momentum does change when the moment of inertia changes due to rotation.
That means the angular momentum of the object is not preserved in some cases. Since the angular momentum should be constant the actual angular velocity should have changed which could result in a tumbling motion of the object. Here's a video which explains the difference between the angular velocity (w; omega) and angular momentum (L)
Because Unity does not preserve the angular momentum such a tumbling motion as shown in the middle lower animation is not possible in Unity.
I would consider this as a bug. Though maybe this was intended, somehow, like the strange drag calculation which does not even follow the documentation.
The thing is I can do a kickflip in real life and thus create the desired movement. I can also recreate the desired rotational movement with the code above. The rotations come from flicking your foot at the nose "corner" of the board, thus pressing the nose down and at the same time causing the board to rotate around its forward axis. This I believe is possible to recreate by using Force$$anonymous$$ode.Impulse since it acts the same as an impact.
It's not that I want to argue but what if your spinning top would do a loop or barrel roll while spinning in the air, wouldn't that be rotations around more than one axis? It's spinning while it's spinning after all.
Thanks for the help so far.
Not really, have you read the angular momentum article? ;)
The problem is we talk here about rigidbody physics. Think of a bullet. Firearms have rifled barrels to give the bullet a spin. This spin prevents a rotation around another axis. In the worst case it flies in a spiral around the line of fire.
angular momentum has always just one rotation axis.
When perfor$$anonymous$$g a kickflip the boars usually just rotates around the forward axis at least that's even the definition ;)
Also keep in $$anonymous$$d that you don't apply torque in real-life. You apply a force at one end. Due to inertia tensor, center of mass, mass and drag it results in a rotation around the center of mass and a movement.
Realistic physics simulation is not an easy task... $$anonymous$$ost the time in games you fake it in some easy way so it look like you want it.
Found a good reference video ;)
I think the most important thing is that you setup your inertia tensor for your board correctly. It has to be much easier to rotate around the forward axis than the side-axis due to mass distribution
Your answer
Follow this Question
Related Questions
Frisbee throw - How would I add roll / pitch to a spinning object? 0 Answers
Compute the torque needed to rotate an object at a constant rate 3 Answers
Returning a rigidbody back to its original x and z rotations through physics forces. 2 Answers
Constant Force doesn't work 0 Answers
Orbit Collision Axis 0 Answers