- Home /
camera Translate
I don't think this is logical, simply a nomenclature issue (similar to my other newbie question)
Rather than having multiple cameras, when I click on on object, I want the camera to jump to another scene (and then eventually back) in .js I write:
var myCamera: Camera;
function OnMouseUp () {
myCamera.transform.position = (0, 0, 0);
}
Thanks in advance Be
@Bentoon - I don't know what you are asking here. By 'scene' do you mean literally load a new scene, or do you mean just another place. What does this code not do that you want to do?
@robertbu (0.0.0) is just a placeholder
This is the error message I get : Assets/Standard Assets ($$anonymous$$obile)/Scripts/moveCamera.js(6,33): BCE0044: expecting ), found ','.
Thanks Be
Answer by robertbu · Jan 14, 2014 at 12:46 AM
Ahhh, a syntax error. The problem is on line 5. You need a Vector3 in front of your position:
myCamera.transform.position = Vector3(0, 0, 0);
@robertbu Thanks. Still error with the way I'm declaring variable error reads: UnassignedReferenceException: The variable myCamera of 'moveCamera' has not been assigned. You probably need to assign the myCamera variable of the moveCamera script in the inspector. UnityEngine.Component.get_transform () moveCamera.On$$anonymous$$ouseUp () (at Assets/Standard Assets ($$anonymous$$obile)/Scripts/moveCamera.js:7) UnityEngine.Send$$anonymous$$ouseEvents:DoSend$$anonymous$$ouseEvents(Int32, Int32)
I can achieve though with out variable via:
Camera.main.transform.Translate(1,1,1);
Thanks
Variables are public by default in Javascript. So in order to get your original script to work (with the syntax fix) select the game object with the script in the Hierarchy. Then drag and drop the camera onto the 'myCamera' variable in the Inspector.