Search Unity

Set Position Not Working

Discussion in 'Scripting' started by CoffeeConundrum, Aug 27, 2016.

  1. CoffeeConundrum

    CoffeeConundrum

    Joined:
    Dec 30, 2013
    Posts:
    46
    Trying to reset the position of the player when the game restarts back to origin and it's not working. The function is being called so I know that this isn't the issue.

    Player Class : http://pastebin.com/ySqnna9V
    Player GameObject :
    upload_2016-8-27_15-41-34.png
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    :confused: you're setting the position to (0,0,0), the transform is at (0,0,0)... not seeing anything wrong there
     
  3. CoffeeConundrum

    CoffeeConundrum

    Joined:
    Dec 30, 2013
    Posts:
    46
    Thats fine its for when the ship has been moving around, died so might be at (-4,5,0) and then needing to be placed back at its original position.
     
  4. SgtZdog

    SgtZdog

    Joined:
    Aug 27, 2016
    Posts:
    30
    Try this:
    Code (csharp):
    1. void Reset() {
    2.     transform.position = new Vector3(0f,0f,0f);
    3.     //Use this instead of transform.position.Set(0f,0f,0f)
    4. }
     
  5. takatok

    takatok

    Joined:
    Aug 18, 2016
    Posts:
    1,496
    Let me ask you this? Is your world bigger than one screen? If so are you moving the camera around to different parts of it. If thats the case just reseting the player back to 0,0,0 will put him "off screen" so to speak if the camera has been moved. You also need to reset the camera back it its original position.
     
  6. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    ok, so what is it's "original position"? if it's not (0,0,0), try setting it to the position you want it to be... o_O
     
unityunity