I’m new to unity and I’m trying to get the hang of it, I’m following this tutorial http://unity3d.com/learn/tutorials/projects/roll-a-ball to try and create movable ball similar to monkey ball. I’ve created a camera that is following the sphere using this code:
public class FollowCamera : MonoBehaviour {
public GameObject target;
public float damping = 1;
Vector3 offset;
void Start() {
offset = target.transform.position - transform.position;
}
void LateUpdate() {
float currentAngle = transform.eulerAngles.y;
float desiredAngle = target.transform.eulerAngles.y;
float angle = Mathf.LerpAngle(currentAngle, desiredAngle, Time.deltaTime * damping);
Quaternion rotation = Quaternion.Euler(0, angle, 0);
transform.position = target.transform.position - (rotation * offset);
transform.LookAt(target.transform);
}
}
While this works correctly and follows the sphere, the controls are very awkward and do not work as expected however if the sphere is changed to a cube or anyother model its works perfectly fine.
Also if anyone has any sites to get me started that would be nice of you.
Thanks