01-15-2014 05:34 AM
01-17-2014 06:28 AM
01-17-2014 09:13 PM
02-18-2014 02:01 AM
02-18-2014 05:43 PM
"bdeschryver" wrote:
Hey Peterrept,
nice script which is similar to one I created.
I am also trying to not only move the player but also set a predefined orientation so that after teleport, it is looking in a set direction.
Did you look into that ? I can't manage to set the OVRPlayerController rotation or let's say it does not affect the camera direction...
02-19-2014 11:38 AM
transform.FindChild ("OVRCameraController").SendMessage ("SetYRotation",(balise.transform.eulerAngles.y));
02-19-2014 12:48 PM
02-19-2014 05:29 PM
public void SetYRotation (float y)
{
YRotation = y;
}
// Teleport.cs by DaveA
// Drop this on an OVRPlayerController, or not. If not, drag the OVRPlayerController onto this in the Inspector. Or not.
// Place 'target' transforms in scene where you want to appear. Put them into 'targets' array.
// Hitting the 'activate key' will jump you there, with target rotation too.
using UnityEngine;
using System.Collections.Generic;
public class Teleport : MonoBehaviour
{
public KeyCode activateKey = KeyCode.T;
public Transform[] targets;
public Transform player;
public int curTarget = 0;
public OVRPlayerController ovrPlayer;
void Start ()
{
if (ovrPlayer == null)
ovrPlayer = GetComponent<OVRPlayerController>();
if (ovrPlayer == null)
ovrPlayer = Object.FindObjectOfType<OVRPlayerController>();
}
void Update ()
{
if (Input.GetKeyDown(activateKey))
{
player.position = targets[curTarget].position;
ovrPlayer.SetYRotation (targets[curTarget].eulerAngles.y -90f);
curTarget = ++curTarget % targets.Length;
}
}
}
09-24-2014 10:03 AM
09-29-2014 07:59 AM
"DaveA" wrote:
Well looking at my old code, it was just using the OVRCameraController, and the OVRPlayerController will override the rotation. So you have to modify OVRPlayerController to add this:public void SetYRotation (float y)
{
YRotation = y;
}
Then use this script:// Teleport.cs by DaveA
// Drop this on an OVRPlayerController, or not. If not, drag the OVRPlayerController onto this in the Inspector. Or not.
// Place 'target' transforms in scene where you want to appear. Put them into 'targets' array.
// Hitting the 'activate key' will jump you there, with target rotation too.
using UnityEngine;
using System.Collections.Generic;
public class Teleport : MonoBehaviour
{
public KeyCode activateKey = KeyCode.T;
public Transform[] targets;
public Transform player;
public int curTarget = 0;
public OVRPlayerController ovrPlayer;
void Start ()
{
if (ovrPlayer == null)
ovrPlayer = GetComponent<OVRPlayerController>();
if (ovrPlayer == null)
ovrPlayer = Object.FindObjectOfType<OVRPlayerController>();
}
void Update ()
{
if (Input.GetKeyDown(activateKey))
{
player.position = targets[curTarget].position;
ovrPlayer.SetYRotation (targets[curTarget].eulerAngles.y -90f);
curTarget = ++curTarget % targets.Length;
}
}
}