using RayFire; using UnityEngine; public class Missle : MonoBehaviour { public Transform targetTrans; public float moveSpeed = 10; public float rotateSpeed = 5; private void FixedUpdate() { if (targetTrans == null) return; var dir = targetTrans.position - this.transform.position; var targetRot = Quaternion.LookRotation(dir, Vector3.up); this.transform.rotation = Quaternion.Slerp(this.transform.rotation, targetRot, Time.fixedDeltaTime * rotateSpeed); this.transform.position += this.transform.forward * moveSpeed * Time.fixedDeltaTime; } private void OnCollisionEnter(Collision collision) { if (collision.transform == targetTrans) { targetTrans.GetComponent().physics.velocity = (targetTrans.position - this.transform.position).normalized * 100.0f; } } }