Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

How can I reference a camera to move it?

$
0
0
Just trying out some basics, failing hard! In my script attached to the camera gameobject, I've attached the camera to the var camera001. Here's the script, where I'm trying to assign a new position to endMarker before moving the camera with lerp (not got there yet..): #pragma strict var camera001 : Camera; // Transforms to act as start and end markers for the journey. var startMarker: Transform; var endMarker: Transform; function Start () { startMarker = camera001.main.transform; } function Update () { if (Input.GetKeyDown ("m")){ endMarker.position = Vector3(startMarker.position.x+1,startMarker.position.y+1,startMarker.position.z+1); Debug.Log (endMarker.position.x); } } Debug says: "The variable endMarker of 'CameraMover' has not been assigned." I don't fully understand the problem; if I've declared endMarker as a Vector3, why can't I just send it a position?

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>