Hi, I’m trying to get a camera to stay 2 units behind an object on the X axis and 0.5 units above it on the Y axis. This is my code thus far, but I keep getting an error message saying that I’m missing a semicolon. Any help would be appreciated.
My code:
Var CameraTarget : Transform;
Var FollowCamera : Transform;
function Update () {
FollowCamera.transform.position = vector3((CameraTarget.transform.position.X - 2), (CameraTarget.transform.position.Y + 0.5), -10);
}
I’m not sure if this is your problem, but I think that the X and Y that are used as properties of transform.position should be lower case. Try this:
Var CameraTarget : Transform;
Var FollowCamera : Transform;
function Update () {
FollowCamera.transform.position = vector3((CameraTarget.transform.position.x - 2), (CameraTarget.transform.position.y + 0.5), -10);
}
You should check out the camera orbit script from standard assets, after some simple modifications (or none, depending on what exactly are you trying to achieve) itll work fine as camera follow script.
The problem is with your capitalization. The script should read:
var CameraTarget : Transform;
var FollowCamera : Transform;
function Update () {
FollowCamera.transform.position = Vector3((CameraTarget.transform.position.x - 2), (CameraTarget.transform.position.y + 0.5), -10);
}