Advertisement
MatiGe

SoldierAnim

Dec 15th, 2022
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class SoldierAnim : MonoBehaviour
  6. {
  7. public Animator anim;
  8.  
  9. public bool lookY;
  10. public bool lookX;
  11. public float ang;
  12. public Vector2 bjV;
  13. public Vector2 soldierV;
  14. public Soldier s;
  15. public Transform bj;
  16. public FOV field;
  17. public Transform soldier;
  18. public Vector3 mov;
  19. public Bullet b;
  20.  
  21. // Start is called before the first frame update
  22. void Start()
  23. {
  24. anim = GetComponent<Animator>();
  25. ang = 0.0f;
  26. }
  27.  
  28. // Update is called once per frame
  29. void Update()
  30. {
  31. anim.SetFloat("X", s.dirX);
  32. anim.SetFloat("Y", s.dirY);
  33. anim.SetBool("Dead", s.dead);
  34.  
  35. if(s.attack == true)
  36. {
  37. anim.SetTrigger("Attack");
  38. }
  39.  
  40. if(field.canSee == true)
  41. {
  42. bj = GameObject.FindWithTag("BJ").transform;
  43.  
  44. Vector3 dire = bj.position - soldier.gameObject.transform.position;
  45.  
  46. //float angle = Mathf.Atan2(dire.y, dire.x) * Mathf.Rad2Deg;
  47.  
  48. dire.Normalize();
  49.  
  50. s.mov = dire;
  51.  
  52.  
  53. anim.SetFloat("X", s.mov.x);
  54. anim.SetFloat("Y", s.mov.y);
  55. //s.firepoint.transform.position = new Vector3(0f, 0f, 0f);
  56. s.firepoint.position = transform.position + s.mov.normalized;
  57. //s.firepoint.transform.Rotate(0, 0, s.mov.z * 360);
  58. //s.mov = new Vector2(s.dirX * s.bSpeed, s.dirY * s.bSpeed);
  59. //b.Dir = mov;
  60. }
  61. }
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement