x


Switch the camera when object is clicked!

Hello everyone, I have a 2 cameras, and I have a prefab appearing on the screen rendered by the secondary cam. When clicked on the prefab(mouseDrag) I want to attach the position of the prefab to the mouse position. But I want that the main cam renders the prefab after Dragged, so I need to switch the cam that renders my prefab. any hints?

more ▼

asked May 28 '12 at 12:14 AM

moghes gravatar image

moghes
1.4k 18 37 52

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

2 answers: sort voted first

I suppose you select which camera renders the object by defining a culling mask for the respective layer the object is in. To switch the rendering camera for that GameObject, just change the layer property to something cam1 will render but cam2 won't

more ▼

answered May 28 '12 at 12:59 AM

hathol gravatar image

hathol
1.6k 4 11

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

If I'm understand right, could you do something like this?

void OnMouseDown()
{
  transform.position = Camera.main.transform.position;
}

It sounds like you may also need to use layering.

more ▼

answered May 28 '12 at 01:08 AM

Baconaise gravatar image

Baconaise
128 3 5 7

(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:

x3130
x1288
x17

asked: May 28 '12 at 12:14 AM

Seen: 345 times

Last Updated: May 28 '12 at 01:08 AM