Untitled
plain_text
2 months ago
807 B
0
Indexable
Never
private void TestPhysics() { gotHitByAgrenade = true; StartCoroutine(ApplyExplosionForce(playerRigidbody, testVector * testForce)); } private IEnumerator ApplyExplosionForce(Rigidbody2D rb, Vector2 force) { float elapsedTime = 0f; // Adjust the duration to control the acceleration speed while (elapsedTime < duration) { float normalizedTime = elapsedTime / duration; //force = new Vector2(xCurve.Evaluate(normalizedTime) * force.x, yCurve.Evaluate(normalizedTime) * force.y); float accelerationFactor = accelerationCurve.Evaluate(normalizedTime); rb.AddForce(force * accelerationFactor, ForceMode2D.Force); elapsedTime += Time.deltaTime; yield return null; } }