using UnityEngine; public class TracerRound : MonoBehaviour { public GameObject bullet; public GameObject bulletSpawnPos; private TracerTarget target; private MoveTransform move; private bool done; private void Start() { move = GetComponent(); bullet = Object.Instantiate(bullet, bulletSpawnPos.transform.position, bulletSpawnPos.transform.rotation); bullet.GetComponent().damage *= base.transform.localScale.x; GetComponentInParent().CopySpawnedAttackTo(bullet); target = bullet.GetComponent(); GetComponentInParent().AddHitActionWithData(Hit); bullet.GetComponentInParent().AddHitActionWithData(Hit); } public void Hit(HitInfo hit) { if ((bool)hit.transform.root.GetComponent()) { base.transform.SetParent(null); base.gameObject.AddComponent().seconds = 10f; base.gameObject.AddComponent().target = hit.transform; } } private void Update() { if (target != null) { target.SetPos(base.transform.position, Vector3.Cross(Vector3.forward, base.transform.forward), move); } if (bullet == null && !done) { done = true; GetComponentInChildren().Stop(); } } }