- Home /
Can SteamVR trigger simulate Fire1?
Hello, I normally figure out my own problems simply by searching around the internet but I'm bashing my head on the wall right now after hours of searching.
I have an old game I'm trying to convert to VR, and i need my Vive triggers to simulate mouse buttons true for the following if statements to fire the weapons that are children to the vive controllers. The script this code is in, is attached to the weapons themselves not the controllers. And the code is in update ()
if (fireTimer >= actualROF && burstCounter < burstRate && canFire)
{
if (Input.GetButton("Fire1"))
{
if (!warmup)
{
Fire();
}
else if (heat < maxWarmup)
{
heat += Time.deltaTime;
}
}
if (warmup && Input.GetButtonUp("Fire1"))
{
if (allowCancel && Input.GetButton("Cancel"))
{
heat = 0.0f;
}
else
{
Fire();
}
}
}
Currently everything runs fine except I still need to click the mouse to fire. I've tried using
SteamVR_TrackedController controller;
void Start () {
controller = GetComponent<SteamVR_TrackedController>();
if (controller == null)
{
controller = gameObject.AddComponent<SteamVR_TrackedController>();
}
controller.TriggerClicked += new ClickedEventHandler(SimulateMouse);
}
void SimulateMouse(object sender, ClickedEventArgs e)
{
//Somehow simulate a mouse click?
}
To no avail as I couldn't figure out what to put in SimulateMouse... I swear I've looked all over and maybe the answer is under my nose, if so I apologize for the double post.
Thanks for reading.
Still no advice? It's been a few days since I've posted this, any help would be great.