Jump to content

teleporting on vive focus plus, ue 4.21, sdk 3.0.2


Recommended Posts

I'm having some issues with using the sample code for teleporting. I'm an absolute beginning with blueprints and i think thats mainly the cause. That said, can anyone comfirm they have it working with controller follow using the controllers and *not* gaze?

 (tag added by moderator) 

Link to post
Share on other sites

step 1 - WaveVR and ControllerLoader prefab make child of empty gameobject then create script and attach to this empty gameobject.

 

public class TeleportScript : MonoBehaviour
{
public static TeleportScript instance;

public static TeleportScript Instance
{
get
{
if (instance == null)
{
instance = new TeleportScript();
}
return instance;
}
}

private Transform sourceCam;
//public Transform targtPos;
private SampleScript sample;
// Start is called before the first frame update
void Start()
{
sourceCam = this.transform;
ControllerRay._teleport += TeleportParam;
}

public void TeleportParam(Vector3 target)
{
Vector3 pos = new Vector3(
target.x,
sourceCam.position.y,
target.z);

//Interop.WVR_InAppRecenter(WVR_RecenterType.WVR_RecenterType_YawAndPosition);

sourceCam.position = pos;
sample.display.text += sourceCam.position.ToString();
}
}

 

step 2 -- make "ControllerPrefab" to public in "WaveVR_ControllerLoader" script.

then i have created ControllerRay script and attached it to controller i.e dominant 

 

public class ControllerRay : MonoBehaviour
{
public delegate void TeleportAction(Vector3 t);
public static event TeleportAction _teleport;

private WaveVR_ControllerLoader controller_right;
public GameObject sphere;
private SampleScript sample;
// Start is called before the first frame update
void Start()
{
controller_right = GetComponent<WaveVR_ControllerLoader>();
sample = FindObjectOfType<SampleScript>();
}

// Update is called once per frame
void Update()
{

RaycastHit hit;
Vector3 c_pos = controller_right.GetComponent<WaveVR_ControllerLoader>().ControllerPrefab.transform.position;
Vector3 direction = controller_right.GetComponent<WaveVR_ControllerLoader>().ControllerPrefab.transform.forward;
Debug.DrawRay(c_pos, direction, Color.red);

if (Physics.Raycast(c_pos, direction, out hit))
{

if (hit.collider.tag.Equals("Ground"))
{
bool isClicked = WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Right).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Trigger);
if (isClicked)
{
sample.display.text = "condition checked";
_teleport(hit.point);
}
}

}
}

}

 

step 3 - add plane in the  scene and tag it as "Ground"

Link to post
Share on other sites

Please sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...