Leadwerks Game Engine 4.4 features an upgrade to the latest version of Newton Dynamics, along with a bunch of new features to enhance physics.
The new kinematic controller is a joint that lets you specify a position, rotation (Euler or quaternion), or a 4x4 matrix to orient the body to. You can set the maximum linear and angular force the joint may use to orient the entity. This allows you to create a kinematic controller that only affects position, only affects rotation, or one that controls both at once. In the video below I am using a kinematic controller to create a simple IK system with two hinge joints. The end effector is controlled by the mouse position, while the base entity stays in place, since it has zero (infinite) mass:
The kinematic controller provides much more stable collisions than the Entity PhysicsSetPosition() and PhysicsSetRotation() commands, and should be used in place of these. In fact, these commands will be removed from the documentation and should not be used anymore, although they will be left in the engine to ensure your code continues to work. The FPS player script will be updated to use a kinematic control for objects you are holding, which will eliminate the energetic collisions the script currently produces if you pick up a crate and push it into the wall.
The new joint commands are as follows:
static Joint* Kinematic(Entity* entity, const Vec3& position); virtual void SetTargetMatrix(const Mat4& mat); virtual void SetTargetPosition(const float x, const float y, const float z, const float blend = 0.5); virtual void SetTargetPosition(const Vec3& pos, const float blend = 0.5); virtual void SetTargetRotation(const float pitch, const float yaw, const float roll, const float blend = 0.5); virtual void SetTargetRotation(const Vec3& rotation, const float blend = 0.5); virtual void SetTargetRotation(const Quat& rotation, const float blend = 0.5);
For improved constistency in the API, the joint SetAngle function will be renamed SetTargetAngle, but a copy of the old command will remain in the engine:
virtual void SetTargetAngle(const float angle);
Hinge joints can now accept a friction value to make them more resistant to swinging around. I used this in the example below to make the joints less "loose", while a kinematic controller positions the green box:
New Vehicle Model
Newton 3.14 features a new vehicle model with a realistic simulation of a slip differential. Power is adjusted to each wheel according to the resistance on each tire.
Watch closely as the wheels below act just like a real car does when its tires slip:
The realistic vehicle models gives vehicles a much more visceral and fun feeling. The new vehicle also uses actual bodies for the tires, instead of convex raycasts, so the sudden bouncing the old vehicles could exhibit if the chassis didn't encompass the tires is eliminated.
Slider and hinge joints now have optional spring behavior you can enable with one command. Use this to make our own custom suspension system, or anything else you need.
void SetSpring(const float spring)
These changes will be available next week on the beta branch on Steam.