Hi, I’m trying to make a flying vehicle as well, in a Unity VRChat World Project. My controls for the vehicle work just fine, but when I hop into VR, the vehicle controls and default player controls, they both function simultaneously. I want only the vehicle controls to function. Is there a way to perhaps disable default player controls(analog sticks of quest controllers), or modify them with my vehicle controls?
Flying Control Script
This is the script I have attached to my flying vehicle gameobject.
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class inputget : UdonSharpBehaviour
{
private Rigidbody rigid;
public float rotateSpeed=50f;
public float moveSpeed = 50f;
void Start()
{
Rigidbody rigid = GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
float pitch = Input.GetAxis("Oculus_CrossPlatform_SecondaryThumbstickVertical");
float throttle = Input.GetAxis("Oculus_CrossPlatform_PrimaryThumbstickVertical");
float yaw = Input.GetAxis("Oculus_CrossPlatform_PrimaryThumbstickHorizontal");
float roll = Input.GetAxis("Oculus_CrossPlatform_SecondaryThumbstickHorizontal");
//VR Controls
if (yaw>0)
{
transform.Rotate(Vector3.forward * -rotateSpeed * Time.deltaTime, Space.Self);
}
else if(yaw<0)
{
transform.Rotate(Vector3.forward * rotateSpeed * Time.deltaTime, Space.Self);
}
if (throttle > 0)
{
transform.Translate(Vector3.up * moveSpeed * Time.deltaTime, Space.Self);
}
else if (throttle < 0)
{
transform.Translate(Vector3.down * moveSpeed * Time.deltaTime, Space.Self);
}
if (pitch > 0)
{
transform.Rotate(Vector3.right * moveSpeed * Time.deltaTime, Space.Self);
}
else if (pitch < 0)
{
transform.Rotate(Vector3.left * moveSpeed * Time.deltaTime, Space.Self);
}
if (roll > 0)
{
transform.Rotate(Vector3.down * moveSpeed * Time.deltaTime, Space.Self);
}
else if (roll < 0)
{
transform.Rotate(Vector3.up * moveSpeed * Time.deltaTime, Space.Self);
}
//Desktop Controls
//yaw
if (Input.GetKey(KeyCode.D))
{
transform.Rotate(Vector3.up * moveSpeed * Time.deltaTime, Space.Self);
}
else if (Input.GetKey(KeyCode.A))
{
transform.Rotate(Vector3.down * moveSpeed * Time.deltaTime, Space.Self);
}
//throttle
if (Input.GetKey(KeyCode.W))
{
transform.Translate(Vector3.up * moveSpeed * Time.deltaTime, Space.Self);
}
else if (Input.GetKey(KeyCode.S))
{
transform.Translate(Vector3.down * moveSpeed * Time.deltaTime, Space.Self);
}
//pitch
if (Input.GetKey(KeyCode.UpArrow))
{
transform.Rotate(Vector3.right * moveSpeed * Time.deltaTime, Space.Self);
}
else if (Input.GetKey(KeyCode.DownArrow))
{
transform.Rotate(Vector3.left * moveSpeed * Time.deltaTime, Space.Self);
}
//roll
if (Input.GetKey(KeyCode.LeftArrow))
{
transform.Rotate(Vector3.forward * rotateSpeed * Time.deltaTime, Space.Self);
}
else if (Input.GetKey(KeyCode.RightArrow))
{
transform.Rotate(Vector3.forward * -rotateSpeed * Time.deltaTime, Space.Self);
}
}
}