S
S
strelok_10142021-01-18 21:19:14
Unity
strelok_1014, 2021-01-18 21:19:14

Error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement?

Good afternoon, I have a problem with the code (c#) for the beetle sprite. I rechecked my code several times, but still I get an error:

Assets\Scripts\Beetle.cs(42,9): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

I will be glad if you help)

My code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Beetle : MonoBehaviour
{
    public float speed = 4f;
    bool isWait = false;
    bool isHidden = true;
    public float waitTime = 4f;
    public Transform point;

    void Start()
    {
        point.transform.position = new Vector3(transform.position.x, transform.position.y + 1f, transform.position.z);
    }
    
    void Update()
    {
        if (isWait == false)       
            transform.position = Vector3.MoveTowards(transform.position, point.position, speed*Time.deltaTime);   
        if (transform.position == point.position)
        {
            if (isHidden)
            {
                point.transform.position = new Vector3(transform.position.x, transform.position.y + 1f, transform.position.z);
                isHidden = false;
            } else
            {
                point.transform.position = new Vector3(transform.position.x, transform.position.y - 1f, transform.position.z);
                isHidden = true;
            }

            isWait = true;
            StartCoroutine(Waiting());
        }
    }
    
    IEnumerator Waiting()
    {
        yield return new WaitForSeconds(waitTime);
        isWait == false;
    }   
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fallenyasha, 2021-01-18
@strelok_1014

isWait == false;
replace with
isWait = false;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question