- Home /
Why doesn't my VR iron man flight system work?
[INFO] Headset: Oculus Quest, I am using Oculus Link. Controllers Oculus Quest touch controllers.
I'm trying to create an accurrate iron man flight system like the one in Richies Plank Experience, but the player often goes in the wrong direction. using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Flight : MonoBehaviour
{
public Transform rightController;
public Transform leftController;
private ParticleSystem rightControllerFlames;
private ParticleSystem leftControllerFlames;
public float moveSpeed;
public Rigidbody rb;
public AudioSource jetSound;
private bool flamesNotPlaying;
public Transform cam;
private void Awake()
{
rightControllerFlames = rightController.GetComponentInChildren<ParticleSystem>();
leftControllerFlames = leftController.GetComponentInChildren<ParticleSystem>();
}
private void Update()
{
if (leftControllerFlames.isPlaying == false && rightControllerFlames.isPlaying == false)
{
flamesNotPlaying = true;
jetSound.Stop();
}
else
{
flamesNotPlaying = false;
}
var rightControllerFlamesEmission = rightControllerFlames.emission;
var leftControllerFlamesEmission = leftControllerFlames.emission;
rightControllerFlamesEmission.rateOverTime = ButtonIsPressed.rightTriggerValue * 100;
leftControllerFlamesEmission.rateOverTime = ButtonIsPressed.leftTriggerValue * 100;
}
void FixedUpdate()
{
if (ButtonIsPressed.rightTriggerValue > 0.1f)
{
rightControllerFlames.Play();
jetSound.volume = ButtonIsPressed.rightTriggerValue;
if (!jetSound.isPlaying && !flamesNotPlaying)
{
jetSound.Play();
}
//float forceX = ButtonIsPressed.rightTriggerValue * (rightController.position.x);
//float forceY = ButtonIsPressed.rightTriggerValue * (rightController.position.y);
//float forceZ = ButtonIsPressed.rightTriggerValue * (rightController.position.z);
Vector3 forceVector = rightController.eulerAngles.normalized * ButtonIsPressed.rightTriggerValue * moveSpeed * Mathf.Rad2Deg;
rb.AddForce(forceVector);
}
else
{
rightControllerFlames.Stop();
}
if (ButtonIsPressed.leftTriggerValue < 0.01f && ButtonIsPressed.rightTriggerValue < 0.01f)
{
if (jetSound.isPlaying)
{
jetSound.Stop();
}
}
if (ButtonIsPressed.leftTriggerValue > 0.1f)
{
leftControllerFlames.Play();
jetSound.volume = ButtonIsPressed.leftTriggerValue;
if (!jetSound.isPlaying && !flamesNotPlaying)
{
jetSound.Play();
}
//float forceX = ButtonIsPressed.leftTriggerValue * (leftController.position.x);
//float forceY = ButtonIsPressed.leftTriggerValue * (leftController.position.y);
//float forceZ = ButtonIsPressed.leftTriggerValue * (leftController.position.z);
Vector3 forceVector = rightController.eulerAngles.normalized * ButtonIsPressed.rightTriggerValue * moveSpeed* Mathf.Rad2Deg;
rb.AddForce(forceVector);
}
else
{
leftControllerFlames.Stop();
}
}
}
Comment
Is the force vector when pressing the left trigger supposed to be calculated using the right controller's values? (line 89) It looks like maybe you've copy-and-pasted the section for the right controller but then not changed all the necessary rights to lefts