- Home /
Camera Follow sphere with ridgidbody?
Trying to make a script that will make the main camera folow the sphere ingame. I can get it to follow just fine, but when it comes to dramatically rolling with the sphere, its not a pretty sight. How can I just make it follow, and not roll around with the ball as if it is focusing on a single point of the sphere but instead just follow the sphere in general ?
Answer by Andrew_Kenady · Mar 28, 2014 at 03:35 PM
You can add a script to the camera that simply updates the camera's position to the player's position.
Something like this:
public class CameraScript : MonoBehaviour
{
public GameObject player;
private Vector3 _offset;
public void Start()
{
_offset = transform.position - player.position;
}
public void Update()
{
transform.position = player.position + _offset;
}
}
The beginner Unity tutorial, Roll-a-ball, has an example of this. http://unity3d.com/learn/tutorials/projects/roll-a-ball
Answer by giantkilleroverunity3d · Mar 28, 2014 at 04:18 PM
Thank you for this. I need to change my approach in another question I posted. I was trying to have an instantiated object tell the secondary camera to follow it. The secondary camera was jerking, unstable and rotating wrong. This points to competing scripts in seperate objects. Key statement here.
Answer by ObamaUnicorn · Mar 07, 2017 at 04:21 PM
i follow the script properly and there is still no player slot in the main camera inspector please help
Your answer
Follow this Question
Related Questions
Smooth Follow Problem 1 Answer
Camera follow smoothness problem 1 Answer
Why does the camera smoothly follow in one direction but not the other? 0 Answers
[Closed] SmoothFollow trouble 0 Answers