Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Unity SteamVR teleportation on moving teleportation area

Discussion in 'VR' started by androidbritvaokama, Aug 16, 2023.

  1. androidbritvaokama

    androidbritvaokama

    Joined:
    Nov 11, 2021
    Posts:
    2
    Hello, I have the ship in my Unity VR scene, that moves in space via the animation with animator component on it. Also on this ship I have a teleportation area and player, that are parented to ship prefab, so they are moving with it. When I try to teleportate my player at some point on teleportation area, I have an issue that at the time of frame update teleportation area moves a little and player appears a little behind from teleportation area.

    I drawn a little scheme, that , that illustrate my problem. The top part of this scheme is my start situation, when player whants to teleport to red point. And the bottom part is the situation after teleportation: the ship with teleportation area moves forawrd, and player appears on red point, neither green.


    Maybe someone could help me?
     
  2. androidbritvaokama

    androidbritvaokama

    Joined:
    Nov 11, 2021
    Posts:
    2
    Well, if someone will face this problem, here is my solituion: the idea is really simple, just add difference in teleportation area postion in time to player postion after teleportation.
    So in teleport.cs, I saved teleportation object, and it's postition before teleportation and after player teleportation, i added such code:
    Code (CSharp):
    1. teleportObjectPositionAfterTeleportation = teleportObject.transform.position;
    2.                 diffInPositions = teleportObjectPositionAfterTeleportation - teleportObjectPositionBeforeTeleportation;
    3.                 player.trackingOriginTransform.position += diffInPositions;