Friday, July 29, 2022
HomeGame Developmentunity - How do I revert again to "regular" velocity after a...

unity – How do I revert again to “regular” velocity after a slight increase hitting a collider mid-air?


How do I revert again to “regular” velocity after a slight increase from hitting a collider mid-air?

personal void OnCollisionEnter2D(Collision2D collision)
{
    var Velocity = lastVelocity.magnitude;
    var Path = Vector3.Replicate(lastVelocity.normalized, collision.GetContact(0).regular);
    rb.velocity = Path * Mathf.Max(Velocity, 0f);

    if (collision.gameObject.CompareTag("Blocker"))
    {
        rb.AddForce(Path * 5f, ForceMode2D.Impulse);
    }

}

I am utilizing AddForce & it really works however the factor is, it would not revert again to regular velocity. I used to be advised to attempt forcemode.impulse but it surely did not work.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments