Answer the question
In order to leave comments, you need to log in
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
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question