Physics sub-stepping is a great feature. Having the “free the physics” approach would be much better than the semi-fixed timestep however in my opinion. All physics-based game/simulation would greatly benefit of the fixed timestep and the reproducible physics of the “free the physics” approach. But it’s still an interesting feature.
One question though: do you plan to expose the “physics tick” of the sub-stepping in Blueprint ? That would be extremely useful. I have a case where enabling sub-stepping without having access to the physics tick breaks things… I’m going to explain it so you can have an actual example and might see the value in exposing it.
I’m trying to prototype a UAV simulator (quadcopter for now) using Blueprints. The modelling of the quadcopter is physics-based. What I mean by that is that the quadcopter has 4 thrusters (imagine a X shape with a propeller at each corner and I placed a thruster at each propeller’s location). The motion of the quadcopter is entirely controlled by the strength set for the thrusters. In this situation, if the object on which I have my 4 thrusters attached (my mesh) is perfectly balanced (if my center of mass is exactly at the center of the 4 thrusters), setting the same thrust value for each propeller will keep my quadcopter perfectly horizontal (no roll and no pitch). On the other hand, if I want to turn right, I increase the thrust on the left propellers and reduce the thrust on the right propellers. However, as with actual quadcopters, if I send a command to the quad to turn left by 10 degrees, I have no way to know how much thrust is needed to achieve 10 degrees (it’s a non-linear problem and it might depends on external conditions like wind for instance). So the solution is to implement PID controllers on each axis to control the motion correctly. For those not familiar with PID controllers, this is the idea behind it: let’s say I ask for a 10 degrees angle to the right (so target = 10 degrees) and my quadcopter is currently horizontal (so actual = 0 degree). We calculate the error (target - actual) and we use this error and some PID coefficients to compute a correction (the simplest case would be to compute a correction = constant * error). In my case, I produce a correction to modulate the propeller speeds, which in turn changes the thrust produced by each propeller. The next frame, the quadcopter will have started to move right, and it might be at 6 degrees. So the new error would be 10 - 6 = 4, and the new correction for this frame would be smaller than the previous frame so we can converge towards our target with a smaller and smaller correction until no correction is no longer needed when we are on target.
My control works great and the quadcopter moves as expected. I compute the error between the command (target) and the actual value (current orientation of the quadcopter), use my PID controller to generate a correction to be applied to the propeller speed, which varies the thrust of each propeller and correct the motion of my quadcopter to converge towards the target. To check that, I asked a target of 1 degree and looked at all the values in my simulation at each frame. In less than 10 frames the actual angle was on target (with a decreasing speed when approaching the targeted angle).
So here’s my problem now. When I came across this physics sub-stepping features (and the promise to get an improved physics), I turned it on. And my control stopped working. First, the actual angle seems to converge towards my target of 1 degree, but actually went much beyond the target. When I observe the speed at which it converged towards the target, it first slowed down (as expected since the error decreases, so the amount of correction at each new frame should decrease too) but after a few frames (5 or 6), the speed at which it converged increased. Basically, it does not work.
My guess is that the force is applied at each sub step, the new position/orientation is computed, and my physics simulation is going forward much faster, right? And since I’m doing my control only once by frame, the motion of my quadcopter basically goes uncontrolled during the sub-steps process. I compute a correction based on the current error right before starting a frame. With physics sub-stepping on, after one sub-step, my quadcopter had updated its position/orientation. Even though it’s now closer to the target, the same correction is applied once again (based on the position at the beginning of the frame). Instead, the correction should be reduced after each sub-step since we are getting closer to the target. If I had access to the physics sub-steps, I could update the correction between each sub-step.
Being able to implement the control within each sub-step would also allow it to be executed faster than only at each frame. In real life, the control loop of a quadcopter is executed at frequencies ranging from 100 Hz to 500 Hz. The quadcopter seems more responsive and the quality of the control is better. Doing the control in Unreal Engine at a higher frequency will see my quad to be more responsive too.
I think that giving users more control on the physics (and adding features like sub-stepping) is crucial for serious games. I’m new to UE4 and so far I’m very impressed by it. Keep the great work! We have a custom engine for doing surgical real-time simulation and we consider using UE4 for a few new projets we have (like this UAV simulator). Being able to implement our own physics in a decoupled way from the rendering is crucial. So I just wanted to let you guys know about that.