Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Zombie : MonoBehaviour
- {
- static Animator anim;
- private Transform player;
- private Rigidbody zombie;
- public float speed = 10f;
- void Start()
- {
- player = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
- anim = GetComponent<Animator>();
- zombie = GetComponent<Rigidbody>();
- }
- void Update()
- {
- if (Vector3.Distance(player.position, this.transform.position) < 2.5 )
- {
- Vector3 direction = player.position - this.transform.position;
- direction.y = 0;
- this.transform.rotation =
- Quaternion.Slerp(this.transform.rotation,
- Quaternion.LookRotation(direction), 0.1f);
- anim.SetBool("isIdle", false);
- if (direction.magnitude > 0.4)
- {
- this.transform.Translate(0, 0, 0.0075f);// на что,его можно заменить?
- anim.SetBool("isWalking", true);
- anim.SetBool("isAttacking", false);
- }
- else
- {
- anim.SetBool("isAttacking", true);
- anim.SetBool("isWalking", false);
- }
- }
- else
- {
- anim.SetBool("isIdle", true);
- anim.SetBool("isWalking", false);
- anim.SetBool("isAttacking", false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement