Search Unity

SteamVR2.5 Teleporting onto vertical surfaces? (hired help?)

Discussion in 'AR/VR (XR) Discussion' started by vrod2000, Jul 17, 2020.

  1. vrod2000

    vrod2000

    Joined:
    May 28, 2020
    Posts:
    17
    Hi.

    I am using SteamVR2.5 on the project. For teleporting to an area, rather than create a plane and place ontop of a surface, I have duplicated the target mesh (example a floor tile), then made a collider for it, then applied the Teleport Script to it.

    The above allows me to teleport anywhere or ontop of anything. There is a problem. It allows you to teleport onto a vertical surface. Example: Think of a giant cube that you can teleport ontop of. With the method described above, you can now teleport to the side of the cube as well as the top. I don't mind teleporting onto a slope (like 60 degrees or less), but not a vertical wall.

    Has anyone tackled this issue before, or think they can solve the issue?

    thanks.
     
  2. vrod2000

    vrod2000

    Joined:
    May 28, 2020
    Posts:
    17
    Solved by me!

    1. Declare a public variable in the Teleport.cs script. "public int MaxTeleportGroundAngle;"
    I placed it right under;
    "public SteamVR_Action_Boolean teleportAction = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("Teleport");"
    , but you can place it where you like within the public variables.

    2. Comment out (add a "//" in front of the line) or delete these 2 lines (#429 and #430)
    Vector3 normalToUse = hitInfo.normal;
    float angle = Vector3.Angle( hitInfo.normal, Vector3.up );
    (these lines will get added again in another location in the next step)

    3. Right BEFORE line #346 (should be "HighlightSelected( hitTeleportMarker );") then add the following;

    //Check if the teleport point is within an acceptable slope
    Vector3 normalToUse = hitInfo.normal;
    float angle = Vector3.Angle(hitInfo.normal, Vector3.up);
    if (angle > MaxTeleportGroundAngle)//angle too steep for teleporting
    {hitTeleportMarker = null;}

    I'll look into "player height when teleporting" restrictions later.