Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
labyrinthtest's avatar
labyrinthtest
Honored Guest
12 years ago

FirstPersonController/OVRplayercontroller

Hello,

I made a 3d labyrinth in Unity to measure the time that players need to finish it. For that I've made a script that shows a GUItext with the time spent on the task when the player controller goes through an invisible cube positioned at the end of the track. It worked fine, but when I started using oculus and changed the FirstPersonController for the OVRplayercontroller it stopped working. It is possibly a simple issue, but I'm truly lost on why it doesn't work if it worked with the other controller. I would be very thankful if someone could help me with this. This is the code:

#pragma strict

var tiempo:float;
var tiempoGUI:GUIText;
private var terminado:boolean = false;

function Start(){
Screen.lockCursor = true;
}

function OnTriggerEnter(obj:Collider){
terminado = true;
tiempoGUI.text = "Tiempo: " + tiempo.ToString();
}

function Update(){
if(!terminado){
tiempo += Time.deltaTime;
}
}

5 Replies

Replies have been turned off for this discussion
  • Hi Labyrinthtest,

    I'm a beginner with Unity so please bear that in mind if the below information isn't useful to you! I'm sure one of the many more knowledgeable users on here will be along shortly with the correct answer!

    You don't mention if the problem is that the information (via GUIext) is being displayed at all, or that the information that is being displayed is incorrect.

    2 things I can think of, depending on your problem:

    1. I'm sure there are problems displaying GUItext objects when using the OVRCameras (which OVRPlayerController uses).

    2. Does OVRPlayerController have a collider set up as default?


    Hope this helps anyway....

    Boff
  • The OVRPlayerController prefab does not have a collider or rigidBody so collision isn't going to be checked when you go through your trigger.
  • I'm sorry for not explainning it propperly. The GUIText doesn't show at all. And it still doesn't work when I add colliders or even when I attatch a sphere or a box to the OVRPlayerController. Thank you for your reply!
  • The controller also doesn't have a GUILayer component by default, so you need to add that too.
  • Voilá! I added a GUILayer to one of the OVRplayercontroller's camera and it worked perfectly. Thank you for your help! :D