using UnityEngine; namespace RR.Game2D.Entities.Projectiles { public class PhysicsProjectile : BasicProjectile { protected override void Awake() { base.Awake(); _rb.bodyType = RigidbodyType2D.Dynamic; } public override void Launch(Vector2 direction, float speed = -1f, GameObject thrower = null) { this.owner = thrower; _launched = true; Vector2 dir = direction.sqrMagnitude > 0.0001f ? direction.normalized : Vector2.right; float finalSpeed = (speed > 0f) ? speed : initialSpeed; _rb.simulated = true; _rb.bodyType = RigidbodyType2D.Dynamic; _rb.linearVelocity = Vector2.zero; _rb.angularVelocity = 0f; _rb.AddForce(finalSpeed * _rb.mass * dir, ForceMode2D.Impulse); transform.right = dir; if (thrower != null && ignoreOwnerTime > 0f) StartCoroutine(IgnoreOwnerTemporarily(thrower, ignoreOwnerTime)); } } }