roll a ball tutorial 3 of 8 playmode camera error
I've followed all the steps of the videos to this point (with the exception of using different file names), and now at the end of video 3 of 8 the camera is having an odd issue.
It is supposed to show a birds eye view of the player object and move along with it. My camera preview shows this correctly, just as the video shows.
However when I enter playmode, all that is visible is the blue terrain and the shadow cast by the player object as if the camera was stuck ON the sphere instead of being up in the air.
camera script:
using UnityEngine;
using System.Collections;
public class playercamera : MonoBehaviour {
public GameObject player;
private Vector3 offset;
// Use this for initialization
void Start () {
offset = transform.position = player.transform.position;
}
// Update is called once per frame
void LateUpdate () {
transform.position = player.transform.position + offset;
}
}
The camera otherwise behaves as it should, keeping with the player object, and facing down at a 45 degree angle, It just seems to be stuck in front of the object instead of floating over it.
What's causing this?
Answer by Positive7 · Dec 21, 2015 at 09:42 PM
void Start () {
offset = transform.position - player.transform.position; //Note the change "=" to "-"
}
Of course it would be a silly little mistake like that. Thank you.
Your answer
Follow this Question
Related Questions
Unity 5 Swiching cameras causes missing scene 0 Answers
Compile Error 0 Answers
Advice for Fixed Camera System 0 Answers
Camera won't stay attached to script when play button is pressed 0 Answers