Why is the propeller spinning like this?
Here is the code:
propeller.Rotate(Vector3.down * throttle);
Why is the propeller spinning like this?
propeller.Rotate(Vector3.down * throttle);
It looks like the propeller is rotating around a strange axis, resulting in the unexpected spinning behaviour. This is likely due to the way you’ve set up your propeller’s initial rotation or how the rotation is being applied in the code.
Here are a few things you can check and adjust:
Initial Rotation: Make sure the initial rotation of the propeller object is aligned properly with the axis you want it to rotate around. This can often be an issue if the propeller object’s local axis isn’t aligned as expected.
Rotate Axis: In the line propeller.Rotate(Vector3.down * throttle);
, the Vector3.down is applying the rotation around the world space downward axis. To rotate around the local axis of the propeller, you should use propeller.Rotate(transform.up * throttle);
assuming your propeller’s local up axis is the axis you want to rotate around.
Throttle Value: Make sure the throttle
value is correctly calculated and represents the desired rotation speed. You can print the value of throttle
to ensure it’s within the expected range.
Here’s how the code might look if you’re trying to rotate the propeller around its local up axis:
propeller.Rotate(transform.up * throttle);
Remember that the correct axis to use in the Rotate function depends on how your propeller object is oriented in the scene. You can use Unity’s Gizmos to visualize the local axes of the propeller and ensure you’re applying the rotation correctly.
The easiest way(not preferred) is to create an empty gameobject as a parent of the propeller and rotate that parent object instead!