Search code examples
c#unity-game-enginevirtual-reality

On Trigger enter Unity VR function


So me and some people are developing a VR game and we need to have it when the VR hand Presses the button Some objects are hidden so when the trigger on the collider is entered

So I have the function

public void update()
{
//Called once per frame
}
Private void Ontriggerenter(collider, other)
{
    if ( other.tag == "Hand")
{
    Copper.SetActive(false);
}

Where copper is a public game object

I still have the start and update functions not sure if that's the problem but the button clicks but the function is never triggered dose someone maybe know the problem


Solution

  • the "T" and "E" of OnTriggerEnter should be capitalized and OnTriggerEnter takes a variableof type Collider. I am not sure if you have configured the colliders correctly. Here is how the code should look like

    Private void OnTriggerEnter(collider other)
    {
        if ( other.tag == "Hand")
        {
           Copper.SetActive(false);
        }
    }
    

    You can check out this article on Unity Collision basics to get some basic idea.