- Home /
Question by
Chipsmoony · Nov 23, 2016 at 07:34 AM ·
c#camerascripting problemroll a ball
I copied all the code in my script for the Roll a Ball tutorial to make the camera follow the ball, but the camera is still not following the ball? (It says no code errors)
Here's my code:
using UnityEngine; using System.Collections;
public class CameraController : MonoBehaviour {
public GameObject player;
private Vector3 offset;
void Start()
{
offset = transform.position - player.transform.position;
}
void LateUpdate()
{
transform.position = player.transform.position + offset;
}
}
Comment
Answer by Adam-Mechtley · Nov 23, 2016 at 08:20 AM
Do you have an instance of this CameraController component added to your Camera object in the scene?
Answer by Guy-BarNessim · Nov 23, 2016 at 03:44 PM
Make sure you drag the Player game object into the "Player" field on the Camera's script component within the inspector.
Your answer
Follow this Question
Related Questions
I'm clueless about how to make my script change its position based on how close it is to the wall.. 0 Answers
Unity Camera and transform? 1 Answer
Trying to reset image settings on main camera smoothly 1 Answer
How can I re-spawn a script component that has been destroyed? 2 Answers
Relative AddForce 0 Answers