Physics Motion Controllers

This week I’ve been experimenting with controlling physics, here’s what I’ve come up with.

First you make your motion controller class and implement Simulate

public class ThrusterMotion : PhysicsMotionController
{
    protected override void Simulate(ref Vector3 linearVelocity)
    {
        linearVelocity = Vector3.Forward * 10000.0f;
    }
}

Then you can attach entities to the motion controller.

var motion = new ThrusterMotion();
motion.AttachEntity(ent);

Right now you can only apply linear forces but internally this is what physgun etc use so ideally you’d be also able to use this class to apply constraints to pick up objects.

This isn’t set in stone or how it’s going to end up but it’s the first pass at dealing with applying forces to objects.

30 Likes

This is the sexiest shit I’ve seen this week, and I do have a bomb-ass wife.

Was weird to me at first because I thought you were just throwing them and the physics didn’t look right, then realized they’re thrusters applying constant force.

Pretty damn cool.

the stiffer collisions and lack of visible gap between props is very cool to see. I’m curious about how the physics behave at high speeds or with high forces applied.

Not sure she can be your wife cause I think she has a husband or doggo :dog:

Looking forward to attaching ThrusterMotion on alot of things haha xD

Looks great, I’d love to know more about the physical motion controller!!

Can you apply multiple force controllers to an object? Can we still apply instantaneous force to an object using the default controller or do we need to create a controller anytime we want to apply additional forces?

The velocity is most likely applied additively so yeah definitely can have gmod style thrusters.