Predict the result of Rigidbody2D.AddForceAtPosition

I my 2D space-sim game I want to implement an autopilot.
I have multiple thrusters located around the ship.
I need to predict what impact would firing one of them have on the ship positional and angular velocity.
Any idea how?

Look at the Box2D source for “ApplyForce” or “ApplyLinearImpulse” (used if the force mode is impulse), shown below for convenience. This force is time-integrated into linear/angular velocity.

ApplyForce:

inline void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake)
{
    if (m_type != b2_dynamicBody)
    {
        return;
    }

    if (wake && (m_flags & e_awakeFlag) == 0)
    {
        SetAwake(true);
    }

    // Don't accumulate a force if the body is sleeping.
    if (m_flags & e_awakeFlag)
    {
        m_force += force;
        m_torque += b2Cross(point - m_sweep.c, force);
    }
}

ApplyLinearImpulse:

inline void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake)
{
    if (m_type != b2_dynamicBody)
    {
        return;
    }

    if (wake && (m_flags & e_awakeFlag) == 0)
    {
        SetAwake(true);
    }

    // Don't accumulate velocity if the body is sleeping
    if (m_flags & e_awakeFlag)
    {
        m_linearVelocity += m_invMass * impulse;
        m_angularVelocity += m_invI * b2Cross(point - m_sweep.c, impulse);
    }
}

There’s no need to predict the outcome as you already know that if a thruster on left fires then the ship will go to the right. A simpler method is to just apply a force to the ship depending on the relative position of the target. You can then use the force direction to animate the thrusters to make it seem like they’re individually steering the ship.

To calculate the force:

rb.AddForce(target-(rb.position+rb.velocity*2));

You probably want to do this with simple PDFiltering and a tree of behaviors.

Turn until you’re facing roughly in the direction you want (Eg, to the next waypoint, to the player, to the goal, etc.)

Once you’re pointed properly, use a PDFilter to add thrust and maintain a particular desired speed of travel.

Periodically adjust your heading, etc.

The main tuning will be to avoid overshoot and missing the goal, then endlessly orbiting, turning inward forever.

If you want to play with a PDFilter-driven human-controlled first person spaceship, I made one that’s kinda fun to zoom around once you get the hang of things.

Full source and set up scene in my Proximity Buttons package. The PDFilter at least would be useful to you for speed control via thrusters.

proximity_buttons is presently hosted at these locations:

https://bitbucket.org/kurtdekker/proximity_buttons