- Home /
Third person follow camera on a sphere
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
Answer by Wolferino · Sep 02, 2014 at 02:52 PM
bumperino
The Irony here is that you posted your bump as an Answer which means your question will be removed from the Unanswered section making it even more unlikely to get any answers on it.
Ins$$anonymous$$d of bumping your questions you should think about why your question may have gone unanswered. With this question you have not provided enough details.
You say it does not work as expected. You should then provide us with details about how it should work, why you think what you have done would work and what exactly it does wrong. Saying the controls are awkward give us nothing I am afraid.
If you want some tutorials then Unity has a ton of them: http://unity3d.com/learn/tutorials/modules But you have probably already been to that site.
Your answer
Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
maximum angle for camera 0 Answers
Limit camera RotateAround for an UAV game 0 Answers
Rotating following camera for a sphere 1 Answer
Coding noob struggles to implement first-Person camera rotation. 1 Answer