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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

HELP NEEDED. How to bring object to camera.

Discussion in 'Scripting' started by PeachDev, Mar 17, 2020.

  1. PeachDev

    PeachDev

    Joined:
    Mar 12, 2020
    Posts:
    3
    Hey guys, it seems like I can't find an answer anywhere for this. So I'm making a mechanic in the game where when the player clicks on an object the object snap straight to the middle of the screen and when the player deselects the game object, the object returns to its original position and rotation. Any ideas??
     
  2. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,043
    Does the camera move or the object moves?
    And why is this so hard to figure out on your own?
    You don't need any ideas. Just google "how I set position in Unity"
     
  3. PeachDev

    PeachDev

    Joined:
    Mar 12, 2020
    Posts:
    3
    My camera is what will select the game object, it's so hard because I'm new to c#, I've never learned it before like other languages.
     
  4. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,043
    Ok, well, to position a game object in Unity, you set its transform's position to a coordinate.
    If your target object's transform's position is at X/Y/Z, you make your camera's transform's position to be that exact same value.

    https://docs.unity3d.com/ScriptReference/Transform-position.html

    I suggest you go and watch some tutorials on Unity basics, it's silly to expect that you'll get such a tutorial here.
    This forum is mostly when you're stuck with something really specific, or when you need an insight on how to better orient your mind toward a specific problem and such. For general topics such as "how the hell I move an object in Unity, and what's a position" please google it up, I'm sure there are numerous examples already on Unity Answers and Youtube.