Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Get a list of all forces affecting Rigidbody?

Discussion in 'Physics' started by DimitriX89, Jul 19, 2023.

  1. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550
    I am curious if you can track individual forces affecting an object through API. For example, I need to stop or dampen a specific AddForce.Impulse command that was issued 5 frames ago. Can it be done without writing custom controller that tracks "tasks" of a rigidbody?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
    No because recording all that information would be a complete waste for all those that wouldn't need it.
     
    DimitriX89 likes this.
  3. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550
    Okay, so custom "task manager" is the only option
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
    I don't know what a "task manager" is but if you need all that information then you'd need to record it yourself yes. These are not "tasks" to the physics system, they are a one-time operation to change the velocity.
     
  5. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550
    I mean, the way I tried to do this, I wanted character controller which support multiple forces applied to character (jump, dash, knockback, custom gravity and whatever else), and ability to tweak or cancel any of those forces on demand. So I created a custom list of forces as System.Object class, to iterate and do stuff with them. But it is cumbersome, so I asked if something like that exists as built in feature
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
    No, something so specialized wouldn't be built-in.