- Home /
Make camera follow an instantiated object
I have gone through my code and made a new script that is attached to my "Playermodel" prefab. The problem is that I want my camera called "FallCam" to follow the instantiated object. The script that is on my camera looks like this with my "Playermodel" as the variable for the cameraTransform:
#pragma strict
var cameraTransform : Transform;
var offset = Vector3 (0,0,0);
function Update () {
cameraTransform.position = transform.position + offset;
}
I don't know what I am doing wrong, I want the camera to follow the model that is being instantiated but it does not follow. I have put the script on my camera and added the model as the transform.
Thanks in advance.
Do you mean you put this script on the model and attached the camera as the transform? At a glance, it looks like that's what needs to happen...
Answer by DNP · Aug 03, 2012 at 01:46 AM
I would guess make an invisable Cube, and then using the Update function make it continue to teleport to the position every frame.