Search Unity

  1. Tune in to get all the latest Unity news live from Berlin on June 19, 6pm CEST. Set up a YouTube reminder!
    Dismiss Notice
  2. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  3. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Retrieve force vector applied by physics engine.

Discussion in 'Physics' started by JohnHubner, Jun 11, 2018.

  1. JohnHubner

    JohnHubner

    Joined:
    Dec 29, 2015
    Posts:
    4
    Is there a method that supplies the force vector being applied to a 3D rigidbody by the physics engine when its simulating inertia? Or, would I need to calculate that myself?

    I don't see anything like that in the docs, but I could be blind.
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    477
    You won't be able to get that. Things you have available to you:
    • The Velocity Vector3 property, which tells you how fast and in what direction the object is moving. This will be net of all forces acting on the body, but you could potentially track this over time and reverse engineer the net force between physics updates.
    • For collisions, the collision object has an Impulse property which tells you you the force of the collision. This is useful for knowing how "hard" a collision was, as it takes the object masses into account (versus the relativeVelocity property).
     
  3. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    819
    I do not understand the question. Are you trying to get the sum of gravity vector + deceleration (or acceleration) vector?
     
  4. JohnHubner

    JohnHubner

    Joined:
    Dec 29, 2015
    Posts:
    4
    Thanks. I figured I'd have to calculate it myself from Velocity, I was just really hoping i was wrong.
     
  5. JohnHubner

    JohnHubner

    Joined:
    Dec 29, 2015
    Posts:
    4
    No, I'm assuming that the physics engine is internally calculating a force vector to apply to the rigidbody that simulates the rigidbody's "inertia" while it's in motion. I was hoping to be able to get this directly, rather than having to calculate it from the body's Velocity and mass.
     
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    477
    I doubt it works like that. Inertia isn't a force, it's the default state of an object. Forces may act on an object to slow its velocity over time, but the physics engine isn't adding forces to object to keep them moving on their existing path. The object will keep moving until something (gravity, collision, explosive force, drag, etc) causes it to change velocity.

    Do you want to say why you think you need this "inertia" force? Like, what do you expect to do with that information?
     
    JohnHubner likes this.
  7. JohnHubner

    JohnHubner

    Joined:
    Dec 29, 2015
    Posts:
    4
    Good point. If the physics engine works anything like reality, it was a really bad assumption. I was definitely coming at my problem from the wrong end. I had already decided what I wanted to be the answer, and allowed it to affect my perception of the problem. Newton would probably slap me.

    The reason I was looking for that figure is simply because I like to experiment with creating different types of flight models using various available feedback mechanisms as input for controlling flight characteristics. If there was a simple force vector figure that simulated inertia, it would be less work for me in my current experiment. But, that's what laziness will get you, sloppy thinking.

    It's clear that I'll have to do the legwork and use my own calculations, so I think we can consider this thread usefully answered. Thanks for nudging me back in the right direction.