UnityEngineDanil
@UnityEngineDanil
I'm love Unity Engine!

Как исправить ошибку в трансформе объекта?

Есть вот такой код врага
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Enemy : MonoBehaviour
{
    public int health = 10;
    Animator anim;
    public Transform target;
    public float speed = 3f;
    public float attackRange = 1f;





    public void TakeDamage(int damage)
    {
        health -= damage;

        if(health <= 0)
        {
            anim.SetInteger("Death", 2);
            anim.SetInteger("DeathEnemy", 2);
            Die();
        }
    }
    void Die()
    {
        Destroy(gameObject, 1f);
    }

    void Start()
    {
        
        anim = GetComponent<Animator>();
    }

    void Update()
    {
        transform.LookAt(target);

        if(Vector3.Distance (transform.position, target.position) > attackRange)
        {   
            transform.position += transform.forward * speed * Time.deltaTime;
            if (Input.GetAxis("Horizontal") < 0)
            {
                transform.localRotation = Quaternion.Euler(0, 180, 0);
            }
            if (Input.GetAxis("Horizontal") > 0)
            {
                transform.localRotation = Quaternion.Euler(0, 0, 0);
            }
        }
        
       

    }

}

Проблема в том что враг превращается в тонкий объект когда идет за мной в чем проблема? и когда идет мигает и переворачивается в разные стороны просто так 5ec007219a694104834708.png
  • Вопрос задан
  • 92 просмотра
Пригласить эксперта
Ваш ответ на вопрос

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

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