Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1.  
  2. using UnityEngine;
  3.  
  4.  
  5. public class Zombie : MonoBehaviour
  6. {
  7. static Animator anim;
  8. private Transform player;
  9. private Rigidbody zombie;
  10. public float speed = 10f;
  11. void Start()
  12. {
  13. player = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
  14. anim = GetComponent<Animator>();
  15. zombie = GetComponent<Rigidbody>();
  16. }
  17. void Update()
  18. {
  19.  
  20. if (Vector3.Distance(player.position, this.transform.position) < 2.5 )
  21. {
  22.  
  23. Vector3 direction = player.position - this.transform.position;
  24. direction.y = 0;
  25.  
  26. this.transform.rotation =
  27. Quaternion.Slerp(this.transform.rotation,
  28. Quaternion.LookRotation(direction), 0.1f);
  29.  
  30. anim.SetBool("isIdle", false);
  31. if (direction.magnitude > 0.4)
  32. {
  33.  
  34.  
  35. this.transform.Translate(0, 0, 0.0075f);// на что,его можно заменить?
  36. anim.SetBool("isWalking", true);
  37. anim.SetBool("isAttacking", false);
  38. }
  39. else
  40. {
  41. anim.SetBool("isAttacking", true);
  42. anim.SetBool("isWalking", false);
  43. }
  44. }
  45. else
  46. {
  47. anim.SetBool("isIdle", true);
  48. anim.SetBool("isWalking", false);
  49. anim.SetBool("isAttacking", false);
  50. }
  51.  
  52.  
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement