Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug identifier expected error.

Discussion in 'Visual Scripting' started by pokefan54000, Apr 26, 2023.

  1. pokefan54000

    pokefan54000

    Joined:
    Apr 26, 2023
    Posts:
    1
    I was working with some code from a tutorial and after a lot of indentifier changes I got the errors down to one, and it appears to be at new yield WaitForSeconds(deadTime);

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class vrbutton : MonoBehaviour
    {



    // Time that the button is set inactive after release
    public float deadTime = 1.0f;
    //B001 used to lock down button during its set dead time
    private bool _deadTimeActive = false;
    //public Unity Events we can use in the editor and tie other functions to.
    public UnityEvent onPressed, onRe1eased;
    //Checks if the current collider entering is the Button and sets off OnPressed event.
    private void OnTriggerEnter(collider other)
    {
    if(other.tag == "Button" && !_deadTimeActive)
    {
    onpressed?.Invoke();
    Debug.Log("I am almost out");
    }
    }
    //Checks if the current collider exiting is the Button and sets off OnRe1eased event.
    // It will also call a Coroutine to make the button inactive for however long deadTime is set to.
    private void OnTriggerExit(collider other)
    {
    if(other.tag == "Button" && !_deadTimeActive)
    {
    onReleased?.Invoke();
    Debug.Log("l have been released");
    StartCoroutine(WaitForDeadTime()) ;
    }
    // Locks button activity until deadTime has passed and reactivates button activity.
    }
    IEnumerator WaitForDeadTime();

    bool _deadTimeActive = true;
    new yield WaitForSeconds(deadTime);
    bool _deadTimeActive = false;


    }
     
    Last edited: Apr 28, 2023