@tortik92

Ошибки в Unity как решить(С#)?

Привет!
У меня высветилась ошибка при написании кода.
И я не знаю как их решить.
вот ошибки:
Assets/scripts/AI_bot.cs(40,85): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

вот код:
code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AI_bot : MonoBehaviour {

    public Transform player;
	public float[] distns;
	public float speedR;
	public Transform fireP;
	public Transform fireBullet;
	public bool isAtack = false;
	public Animation anim;
	public float FireDelay;

	// Use this for initialization
	void Start () {
		anim = GetComponent<Animation>();
		player = GameObject.FindGameObjectWithTag("Player").transform;
	}
	
	// Update is called once per frame
	void Update () {
		float distance = Vector3.Distance(transform.position,player.transform.position);
		
		// действие: смотреть и атаковать
		if (distance < distns[0] && distance > distns[1])
			{
		    Quaternion tRot = Quaternion.LookRotation(player.transform.position - transform.position);
		    transform.rotation = Quaternion.Slerp(transform.rotation,tRot,speedR * Time.deltaTime);
		    if(!isAtack){
			StartCoroutine(FarAtack());
			isAtack = true;
		    }
			}
                    } 
		IEnumerator FarAtack()
		{
		  yield return new WaitForSeconds(anim.GetClip("anim_Damage").length/2);
		  GameObject.Instantiate(fireBullet,fireP.transform.position,Quaternion.identity) as GameObject;
		  yield return new WaitForSeconds(anim.GetClip("anim_Damage").length/2);
		  yield return new WaitForSeconds(FireDelay);
		  isAtack = false;
		}
       }
// []

  • Вопрос задан
  • 107 просмотров
Решения вопроса 1
GavriKos
@GavriKos Куратор тега Unity
Первая ошибка юнитей - она не помешают запуску (если я не ошибаюсь)
Вторая - результат оператора as надо куда то присвоить.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы