Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OnTriggerStay(Collider other) // ПОПРОБОВАТЬ ОПРОКИНУТЬ ВСЁ ЭТО ДЕРЬМО ЕРЕЗ OnriggerStay
- {
- if (other.tag == "creep")
- {
- hpcreep = other.gameObject.GetComponent<HPcreep>().hp;
- if (hpcreep > 0)
- {
- if (Time.time > nextFire)
- {
- Debug.unityLogger.Log("hpcreep", hpcreep);
- nextFire = Time.time + fireRate;
- //задаётся вектор создания пули, то есть точка её появления, и создаётся сама пуля
- Vector3 bulletpos = new Vector3(transform.position.x, transform.position.y, transform.position.z + 1.5f);
- GameObject bull = Instantiate(bullet, bulletpos, transform.rotation);
- //создаётся переменная типа мувбулет, и присваевается к ней компонентк мувболет; к переменной pl типа трансформ присваивается вектор крипа в текущем кадре
- // и передаётся в класс Movebullet, в метод SetTarget.
- Movebullet mb = bull.GetComponent<Movebullet>();
- Transform pl = other.gameObject.transform;
- if (pl != null)
- {
- plLast = pl;
- mb.SetTarget(pl);
- //Debug.unityLogger.Log("pl=", pl.position.x);
- Debug.unityLogger.Log("plast=", plLast.position.x);
- }
- else
- {
- mb.SetTarget(plLast);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement