UPDATE Below
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.SceneManagement;
5
6
7 public class ToShowRoom : MonoBehaviour
8 {
9
10 void Update()
11 {
12 if (OVRInput.GetDown(OVRInput.Axis1D.PrimaryHandTrigger))
13 {
14 SceneManager.LoadScene(1);
15 }
16
17 }
18 }
this is my code I am trying to grab a door handle to change scenes. on the door handle i have a box collider that “Is Trigger”
My character is using the OVRPlayercontroller.
i am getting this error, I am new to coding and do not understand whats wrong.
Assets\ToShowRoom.cs(12,30): error CS1503: Argument 1: cannot convert from ‘OVRInput.Axis1D’ to ‘OVRInput.Button’
thanks for the help
While I’m not familiar with the OVRInput, the error is pretty clear. The GetDown method requires an OVRInput.Button type, but you are passing it an OVRInput.Axis1D. So you’re providing the wrong type to the GetDown method.
I suggest looking at the doc and seeing if that can help you.
I changed the “if (OVRInput.GetDown(OVRInput.Axis1D.PrimaryHandTrigger))” to “if (OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger))”
and then got this error
Assets\ToShowRoom.cs(13,13): error CS0029: Cannot implicitly convert type ‘float’ to ‘bool’
I have changed my code and it works now the only problem is that I think because it is coming back true it is constantly jumping back and forth between the scenes. I have box colliders on the door handles but i don’t know how to link the script to that collider.
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.SceneManagement;
5
6
7 public class ToShowRoom : MonoBehaviour
8 {
9
10 void Update()
11
12 {
13
14 OVRInput.Get(OVRInput.RawAxis1D.LHandTrigger);
15 if (true)
16 {
17 SceneManager.LoadScene(1);
18 }
19
20
21 }
22 }
I made another code for the other scene same as this but it is LoadScene(0) which is why I think it is jumping back and forth
Umm…you’re not checking for the input. You’re just checking if(true), so it’s always true…
You need to check if the OverInput.Get is returning true or false.
And you may need an additional check if you are touching the door handle or not.