Kinematic Bodies

Coming from a Unity background, I understand physics in terms of

Static - which is BSP brushes I guess
RigidBody - and regular physics object
Kinematic - they do not receive applied forces but can inflict them.

I want to be able to create the equivalent of the kinematic body. After spending a few hours experimenting and going over many documents, MOVETYPE_PUSH seems to be the answer but I can’t figure out how to get it to move to inflict a push as velocity doesn’t work with that move type. Best I’ve come up with is using ENT:Think() to self.Entity:SetPos() but that seems to teleport the thing rather than move it in a way that the physics engine can respond. Any ideas?

In addition, how does parenting affect physics? It certainly acts like movetype push but other than that it doesn’t seem to be documented.

PhysObj:ApplyForceCenter

PhysObj:ApplyForceOffset

PhysObj:SetVelocity

PhysObj:SetVelocityInstantaneous

PhysObj:SetInertia

PhysObj:SetDamping

Here are some functions that might be of use but if you’re going to make custom entities with certain behaviors you are better off using the Scripted Entity library.

MOVETYPE_PUSH is a tricky beast. Every entity that uses it calls a function named MoveLinear() or something like that, in order to move. It does several things, including setting the velocity of the object. An annoying “feature” is that if one of the variables touched by MoveLinear isn’t set correctly, you won’t get any movement. There is no Lua binding for MoveLinear in gmod, so you have to approximate its behavior. I forget exactly what needs to be done, but you can find a working example of MOVETYPE_PUSH in my gmDoom Maps addon. I do recall that after setting the variable with

Entity:SetSaveValue, I had to set the movetype to MOVETYPE_PUSH again, to change some c++ variable that Lua can’t touch at all.