- Home /
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?
Answer by hathol · May 28, 2012 at 12:59 AM
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
Answer by Baconaise · May 28, 2012 at 01:08 AM
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.
Your answer
Follow this Question
Related Questions
How to pause only specific objects/prefabs? 3 Answers
Spawning problems with cameras 1 Answer
Camera movement based on OnMouseDrag() 0 Answers
Touch position to fit in screen 1 Answer