x


how to move my camera...

Hello guys

I'm just practising with unity and creating very easy scripts. I have created a Camera.. named MyCamera. So I want to move it.. once I clicked a button in my GUI. So I created... my js script... declared my button in my OnGUI function. now: in the OnGUI I declared:

theCamera = GetComponent("MyCamera");

and to change it I thought to use:

theCamera.transform.Translate(Vector3(0,10,0)); but... Unity returns me a message that It's not possible to access an object in this way...so... any suggestion? :)

Many thanks. Giancarlo

more ▼

asked Aug 20 '10 at 03:25 PM

Gianca gravatar image

Gianca
48 18 19 23

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Instead of:

theCamera = GetComponent("MyCamera");

use

theCamera = Camera.main.gameObject;

more ▼

answered Aug 20 '10 at 10:25 PM

Tuti gravatar image

Tuti
410 1 3 9

Tuti, thank you!,

Aug 23 '10 at 02:43 PM Gianca
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3314
x2979
x573
x10

asked: Aug 20 '10 at 03:25 PM

Seen: 4524 times

Last Updated: Aug 20 '10 at 03:25 PM