Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Best way to move camera to mousepositions?

Discussion in 'Scripting' started by frekiidoochmanz, Jun 23, 2016.

  1. frekiidoochmanz

    frekiidoochmanz

    Joined:
    Feb 7, 2016
    Posts:
    158
    Any suggestions?
     
  2. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    An explanation would be nice.
    What EXACTLY do you want to do as I cant quite figure with the 0 explanation you have given?
    Do you want;
    1) A First-Person-Controller style use the mouse to rotate the camera?
    2) Being able to drag the camera with the mouse?
    3) When the mouse reaches a side of the screen, move the camera in that direction?
    Explain please.
     
  3. Nitugard

    Nitugard

    Joined:
    May 10, 2015
    Posts:
    340
    Best way to move the camera to a mouse position is learning trigonometry, vectors and so on - starting from scratch...Or you could just use unity provided methods and save a lot of time - easy and bad way in my opinion.
     
  4. Simplified

    Simplified

    Joined:
    May 28, 2016
    Posts:
    19
    Depends what you're going for. Based on the title, MovePosition and Vector3.Lerp would be what I would do, but you probably want something different since I'm sure that's not exactly the kind of behavior you want.
     
  5. frekiidoochmanz

    frekiidoochmanz

    Joined:
    Feb 7, 2016
    Posts:
    158
    anything, I dont understand how to factor mousePosition.x or y since they both give you screen coordinates and all camera movement is done in world space not screen space. I am having trouble combining the two vectors.
     
  6. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    This should help you on your way:
    https://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html