Forum Discussion
Babimc
7 years agoHonored Guest
Oculus Headset movement
I want to know how can I change in unity the thershold of the method below:
transform.haschanged
At the moment it is so sensitive and it triggers with 0.00001 change in the camera.
We have created an Interactive VR video in unity and we want that everytime the user doesnt use the oculus for 30 seconds, a trailer video starts to play!
We have created the code below but even when the oculus is on the ground, still moves a bit (too sensitive):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class Trailer : MonoBehaviour
{
public int timeOut;
private int timeOutTimer = 0;
private Quaternion gameObjectrotation;
private VideoPlayer videoPlayer;
public float dynamicRange = 100f;
// Use this for initialization
public void Awake()
{
Vector3 lastPos;
videoPlayer = GetComponentInParent<VideoPlayer>();
gameObjectrotation = Camera.main.gameObject.transform.rotation;
InvokeRepeating("ScreenSaver", 0, 1.0f);
}
public void ScreenSaver()
{
timeOutTimer++;
var wMinus = gameObjectrotation.w - dynamicRange;
var wPlus = gameObjectrotation.w + dynamicRange;
var xMinus = gameObjectrotation.x - dynamicRange;
var xPlus = gameObjectrotation.x + dynamicRange;
var yMinus = gameObjectrotation.y - dynamicRange;
var yPlus = gameObjectrotation.y + dynamicRange;
var zMinus = gameObjectrotation.z - dynamicRange;
var zPlus = gameObjectrotation.z + dynamicRange;
var cameraW = Camera.main.gameObject.transform.rotation.w;
var cameraX = Camera.main.gameObject.transform.rotation.x;
var cameraY = Camera.main.gameObject.transform.rotation.y;
var cameraZ = Camera.main.gameObject.transform.rotation.z;
if (cameraW >= wMinus && cameraW <= wPlus && cameraX >= xMinus && cameraX <= xPlus && cameraY >= yMinus && cameraY <= yPlus && cameraZ >= zMinus && cameraZ <= zPlus && timeOutTimer >= timeOut)
{
//Show video
videoPlayer.gameObject.SetActive(true);
videoPlayer.Play();
}
else
{
//Hide Video
videoPlayer.gameObject.SetActive(false);
videoPlayer.Stop();
videoPlayer.frame = 1;
}
if (cameraW > wPlus || cameraW < wMinus || cameraX > xPlus || cameraX < xMinus || cameraY > yPlus || cameraY < yMinus || cameraZ > zPlus || cameraZ < zMinus)
{
timeOutTimer = 0;
}
gameObjectrotation = Camera.main.gameObject.transform.rotation;
}
}Any help would be appreciated! Cheers
Replies have been turned off for this discussion
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 3 years ago
- 1 year ago