Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
886 B
1
Indexable
Never
private void TestPhysics()
   {
      gotHitByAgrenade = true;
      playerRigidbody.AddForce(testVector * testForce, ForceMode2D.Impulse);
      //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;
      }
   }