Question by
LargeMcNards · May 30, 2017 at 02:41 AM ·
c#object
When I try this code, the object shoots up into the air. I'm trying to make the camera follow the object.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class FollowPlayer : MonoBehaviour {
public Transform player;
public Vector3 offset;
// Update is called once per frame
void Update () {
transform.position = player.position + offset;
}
}
Comment
Answer by Bill9009 · May 30, 2017 at 04:11 AM
Try:
Camera.main.transform.position = transform.position + offset;
In this case the "offset" would be how far away the camera would be from the player.
Your answer
Follow this Question
Related Questions
Can't get to work a non behaviour constructor with random generated variables 1 Answer
Rotating & fixing the position of an object to one spot 1 Answer
unity3d instantiate and drag object with mouse 1 Answer
Obstacle Spawner Efficiency 0 Answers
Creating an object using a prefab, with parent, text etc.. 1 Answer