public void RotateToVelocity() { Vector2 dir = Jet.GetComponent <Rigidbody2D>().velocity; float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; Jet.transform.localRotation = Quaternion.AngleAxis(angle, Vector3.forward); }
public void EaseVelocityTo() { t += Time.deltaTime; if (t >= 1 || Jet == null) { GameplayManager.OnUpdateDuringGame -= EaseVelocityTo; } else { Rigidbody2D rigidbody = Jet.GetComponent <Rigidbody2D>(); rigidbody.AddForce(Vector2.Lerp(finalVelocity / 10, finalVelocity, t)); } }