Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. void OnTriggerStay(Collider other) // ПОПРОБОВАТЬ ОПРОКИНУТЬ ВСЁ ЭТО ДЕРЬМО ЕРЕЗ OnriggerStay
  2. {
  3. if (other.tag == "creep")
  4. {
  5.  
  6. hpcreep = other.gameObject.GetComponent<HPcreep>().hp;
  7.  
  8.  
  9. if (hpcreep > 0)
  10. {
  11.  
  12. if (Time.time > nextFire)
  13. {
  14. Debug.unityLogger.Log("hpcreep", hpcreep);
  15. nextFire = Time.time + fireRate;
  16. //задаётся вектор создания пули, то есть точка её появления, и создаётся сама пуля
  17. Vector3 bulletpos = new Vector3(transform.position.x, transform.position.y, transform.position.z + 1.5f);
  18. GameObject bull = Instantiate(bullet, bulletpos, transform.rotation);
  19.  
  20.  
  21. //создаётся переменная типа мувбулет, и присваевается к ней компонентк мувболет; к переменной pl типа трансформ присваивается вектор крипа в текущем кадре
  22. // и передаётся в класс Movebullet, в метод SetTarget.
  23. Movebullet mb = bull.GetComponent<Movebullet>();
  24. Transform pl = other.gameObject.transform;
  25.  
  26. if (pl != null)
  27. {
  28. plLast = pl;
  29. mb.SetTarget(pl);
  30. //Debug.unityLogger.Log("pl=", pl.position.x);
  31. Debug.unityLogger.Log("plast=", plLast.position.x);
  32. }
  33. else
  34. {
  35.  
  36. mb.SetTarget(plLast);
  37. }
  38.  
  39.  
  40. }
  41.  
  42. }
  43.  
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement