Sorry to be asking another question in such a short space of time, but this one has me stumped. I’m trying to make a simple object rotate back and forth. For ease of use (as this script will probably be applied to many objects) I’m trying to get the starting rotation and use it as a basis for rotation via Mathf.PingPong. (It’s intended to be a camera, panning back and forth.)

However, whenever I try to get the starting rotation, it always gives very small values like 0.8 even if the actual rotation value is, say, 40 or 50 degrees in that axis. A few sample measurements it gives are 0.9659258, -0.2588191 and -4.216698e-08, where the actual starting rotation was 90, 0 and 30 respectively. The Mathf.PingPong function works otherwise fine, it’s just these starting angles that aren’t working.

Here’s the code I’m using:

```
using UnityEngine;
using System.Collections;
public class CameraMovement : MonoBehaviour
{
public float rotateSpeed = 0.1F;
public float rotateAmount = 90.0F;
public Quaternion startRotation;
void Awake()
{
startRotation = transform.rotation;
}
void FixedUpdate()
{
transform.rotation = Quaternion.Euler(startRotation.z, Mathf.PingPong(Time.time * rotateSpeed, rotateAmount)+(rotateAmount/2)+(startRotation.y), startRotation.x);
}
}
```