Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

teleport an object to the right place

Discussion in 'Scripting' started by Trild123787898, Mar 19, 2019.

  1. Trild123787898

    Trild123787898

    Joined:
    Dec 9, 2018
    Posts:
    206
    How can I teleport an object to the right place for me? did not find normal documentation
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,514
    I only know how to teleport objects to the wrong place. Sorry.

    (pssst, we need more information)
     
    Joe-Censored and SparrowGS like this.
  3. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Define what place is right, then set game object's trasform position to that coordinates. If you're using physics in your game, thing becoming more complicated.
     
  4. Trild123787898

    Trild123787898

    Joined:
    Dec 9, 2018
    Posts:
    206
    then bad, because I want to teleport the physical body!
     
  5. Trild123787898

    Trild123787898

    Joined:
    Dec 9, 2018
    Posts:
    206
    I need to teleport an object let's say in the target (the object has a rigidbody)
     
  6. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Then you need to save it's velocity along with angular velocity, sleep it or make kinematic, change it's position using rigidbody.position setter, and then restore saved values and wake the body or make it non-kinematic again.
     
  7. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,514