Search Unity

Windows Mixed Reality teleporting

Discussion in 'VR' started by TranSystems, May 10, 2018.

  1. TranSystems

    TranSystems

    Joined:
    Jan 10, 2018
    Posts:
    11
    Is there a script or prefab available for player teleporting that looks and acts like the Cliff House demo in the Mixed Reality Portal app that comes with the Windows Mixed Reality HMDs? What I have found in the Mixed Reality Toolkit on Github so far do not seem to look as good or function as smoothly.
     

    Attached Files:

  2. cyenketswamy

    cyenketswamy

    Joined:
    Jul 24, 2015
    Posts:
    41
    Iam quite surprised the Motion Controller prefab doesnt give a comparable experience as the Cliffhouse. Iam working on a teleporting navigation script, will post once its ready.
     
    soleron likes this.
  3. TranSystems

    TranSystems

    Joined:
    Jan 10, 2018
    Posts:
    11
    That would be awesome!!!
     
  4. cyenketswamy

    cyenketswamy

    Joined:
    Jul 24, 2015
    Posts:
    41
    Heres my basic version of a teleport script you will have to modify it further to get more functionality. Only issue is the main camera doesnt want to change position after you release the trigger button on the motion controller. I can position objects around which works fine. Any solutions to get the camera to update its position. NB You just need a simple scene with some cubes and some object that serves as your teleport indicator. Attach this script to your camera.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.XR.WSA.Input;
    4.  
    5. public class Teleport : MonoBehaviour {
    6.     RaycastHit hit;
    7.     GameObject teleportSpot,cubeBox;  
    8.     Vector3 teleportPos,controllerPos,controllerForward;
    9.     InteractionSourcePose sourcePose;
    10.    
    11.     // Use this for initialization
    12.     void Start () {
    13.         teleportSpot = GameObject.FindWithTag("TeleportSpot");
    14.         teleportSpot.SetActive(false);//hide the teleport object
    15.         teleportPos = teleportSpot.transform.position;
    16.  
    17.         cubeBox = GameObject.FindWithTag("Box2");
    18.  
    19.         InteractionManager.InteractionSourceUpdated += InteractionManager_InteractionSourceUpdated;
    20.        
    21.     }
    22.  
    23.    
    24.  
    25.     private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj)
    26.     {
    27.         sourcePose = obj.state.sourcePose;
    28.  
    29.         //If motion controller trigger button is held down and controller is moved the teleport spot/zone is displayed
    30.         //provide no other objects block the line of sight of the ray with the floor
    31.         if (sourcePose.TryGetPosition(out controllerPos))
    32.         {
    33.             if (sourcePose.TryGetForward(out controllerForward, InteractionSourceNode.Pointer))
    34.             {
    35.                 if (Physics.Raycast(controllerPos, controllerForward, out hit, 20.0f))
    36.                 {
    37.                     //Trigger button is pressed and ray cast intersects the floor
    38.                     if (obj.state.selectPressed && (hit.collider.gameObject.tag == "Floor"))
    39.                     {
    40.                         teleportPos = hit.point;
    41.                         teleportSpot.transform.position = teleportPos;
    42.                         teleportSpot.SetActive(true);
    43.                     }
    44.                 }
    45.             }
    46.  
    47.         }
    48.  
    49.         //check when trigger button is released
    50.         if (obj.state.selectPressed == false)
    51.         {
    52.             teleportSpot.SetActive(false);
    53.             //if the bind button is pressed the cube changes position to the last teleportspot
    54.             if (obj.state.grasped == true)
    55.             {
    56.                 cubeBox.transform.position = new Vector3(teleportPos.x,cubeBox.transform.position.y,teleportPos.z);//Move the cube to the teleport spot
    57.             }
    58.        
    59.             this.transform.position= new Vector3(teleportPos.x, this.transform.position.y, teleportPos.z);//not working main camera not changing to teleport location ??
    60.         }
    61.     }
    62.  
    63.  
    64.     // Update is called once per frame
    65.     void Update () {
    66.        
    67.     }
    68.  
    69.     private void OnDestroy()
    70.     {
    71.         InteractionManager.InteractionSourceUpdated -= InteractionManager_InteractionSourceUpdated;
    72.      
    73.     }
    74. }
    75.  
     

    Attached Files:

  5. yoshi0403

    yoshi0403

    Joined:
    Oct 10, 2017
    Posts:
    2
    I've attached your code, and run.but not worked.

    I guess the questioner want to know how to implement the laser pointer like in the cliff house.
    Is this a script to accomplish that?
     
    francescocagnetta likes this.