Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Ошибка CS0103 в юнити

Стас Ермаков Ученик (103), закрыт 2 года назад
Почему ошибка Assets\Scripts\Enemy.cs(69,25): error CS0103: The name 'startTimeBtwAttack' does not exist in the current context
я нуб

вот код:


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

public class Enemy : MonoBehaviour
{
private float timeBtwAttack;
public float startTimeBrwAttack;
public int health;

public float speed;
public GameObject deathEffect;
public int damage;
private float stopTime;
public float startStopTime;
public float normalSpeed;
private Player player;
private Animator anim;

private void Start()
{
anim = GetComponent<Animator>();
player = FindObjectOfType<Player>();
normalSpeed = speed;
}

private void Update()
{
if(stopTime<= 0)
{
speed = normalSpeed;
}
else
{
speed = 0;
stopTime -= Time.deltaTime;
}
if(health <= 0)
{
Destroy(gameObject);
}
transform.Translate(Vector2.left * speed * Time.deltaTime);
}

public void TakeDamage(int damage)
{
stopTime = startStopTime;
Instantiate(deathEffect, transform.position, Quaternion.identity);
health -= damage;
}
public void OnTriggerStay2D(Collider2D other)
{
if(other.CompareTag("Player"))
{
if(timeBtwAttack <= 0)
{
anim.SetTrigger("attack");
}
else
{
timeBtwAttack -= Time.deltaTime;
}
}
}
public void OnEnemyAttack()
{
Instantiate(deathEffect, player.transform.position, Quaternion.identity);
player.health -= damage;
timeBtwAttack = startTimeBtwAttack;
}
}
Лучший ответ
Сергей Шиманский Мудрец (11829) 2 года назад
Потому:
public float startTimeBrwAttack;
и потому:
timeBtwAttack = startTimeBtwAttack;
Остальные ответы
Похожие вопросы