Search Unity

center camera on object that is right clicked

Discussion in 'Scripting' started by pretender, Mar 7, 2010.

  1. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    865
    is there any easy way in doing this?
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    There is some code in this thread which explains how to use raycasting to detect which scene object is under the mouse. You can get the status of the right mouse button with Input.GetMouseButton and use transform.LookAt on the camera to point it at the target object.