I want to emulate a snake slithering randomly. This is in Update() however, the rotation isn't exactly what I want.
My game object's y rotation starts at 270 degrees. At first it seems to work but it always seems to end up pointing approx. 360 degrees.
float currentY = transform.rotation.y;
// the initial y rotation starts at 270
// seems like it rotates y to be between 350 and 10 degrees only.
// This is not what I want. I want it to randomly turn a little to the left or right,
// and then move forward
transform.rotation = Quaternion.Lerp(
transform.rotation,
Quaternion.Euler(0f, (Random.Range(-10.0f, 10.0f) + currentY), 0f),
(float)(Time.time * .01)
);
rbody.AddForce(transform.forward * speed * 2.5f);
transform.rotationalready uses its current facing direction to rotate, soQuaternion.Euler(0f, (Random.Range(-10.0f, 10.0f)), 0f)would already tell it to turn left or right from its current direction.+ currentYfrom your equation.Euleris rotatesxdegrees - you're asking it to rotatex + currentYdegrees