Good Day
I have a capulse shaped Bacteria with flagela which changes its velocity at random. Now I want it to always be rotated so its “tail” is in the oposite direction of movement. It tried it with the following code:
The simplest way to face the way you move is (Disclaimers: check to make sure you are moving first; give whatever up vector you like; snap or use RotateTowards):
One more problem with Degs and Rads is that Unity thinks 0 degrees is forwards, and goes clockwise. Sin/Cos thinks 0 rads faces right, and goes counter-clockwise. Mathf.Rad2Deg is simply (360/(2*PI)).
Anything needing real math, like you’re doing, it seems like you have to test every step and leave extensive notes. For example, in angle=Sin(...)*Deg2Rad I can’t figure out why the var is angle (sin doesn’t return an angle) or why not Rad2Deg (Sin returns radians, not degrees.)