Thruster Physics problems and Substepping

Hey all!

I’m currently developing a space game, and I’m having some problems with physics.
My idea is similar to this, as in having to activate thrusters in order to move a ship. Unlike that demo, I won’t have destructible ships, and will not use WASD movement, each thruster will be activated manually.

So, In order to test, I created a small “ship”, which is actually just a room(which is spawned and attached at Begin Play), and two Thruster components.
http://i.imgur.com/KG8wtPJm.png

My expectation is that when I activate these two thrusters, the ship will fly in a straight line.
However that is not quite the case. I’ve tested both with and without Substepping. With substepping, I also got different results if playing in full screen.
Look(3x with substepping, then without):

Previously I attempted to do the same without thruster components, using only an Addforce At location, but it also had the same weirdness.

here is my Physics settings:
http://i.imgur.com/mpxTK4Em.png

Is that actually expected, and I’m underestimating the difficulties of a thruster-based design? As in, it is not something I should simple fire and forget, but rather have to manage and have the ship compensate for these changes in course?
Or is it just the physics going wonky due to some other factor?

Any help is appreciated, thanks!

If your mesh and your thrusters are perfectly balanced, then only physics engine inaccuracies will make your ship slightly unstable.
However, it doesn’t look like you have 100% precision in making everything symmetric.

The best option is likely to measure the amount of rotational speed, and modulate the left/right thrusters based on how much the ship is rotating – basically, implementing a simple stability control.
It’s very likely you’ll want to look up PID controller design (proportional - integral - derivative) and apply at least P and I values to your correcting function to make it both stable and straight.

It looks weird, even with asymmetrical placement of engines and asymmetrical collision mesh it shouldn’t wobble like this. Are you constraining it to XY axis? As far as I remember physics doesn’t like that.

Well, they are supposed to be symmetrical, but yes, I can imagine that the slightest difference could cause such behavior. Small deviances would pile up leading to instability.

Oh, interesting, thanks for the PID controller suggestion!
But I must admit that I’m not a really good coder. I have yet to use C++ in UE4, so at the moment I’m only using blueprints. Would a PID controller implemented in Blueprints function well, performance-wise?
Most sites seem to indicate that it is a simple algorithm, but since it would act on the Event Tick (right?), I wonder if it would be slow down the game (even more considering that the position of the thrusters would be determined by the player, not the game, so I would need to calculate a lot of variables).
Not that I wouldn’t use C++ (I’ll eventually use it) but I like Blueprints. I’m more of an artist, so I may be worrying too much :stuck_out_tongue:

I was constraining it to XY, but disabling constraints unfortunately haven’t yielded results :frowning:

By the way, I tested it again and it didn’t do some of the weird “stunts” recorded on the video (specifically, the Substepped fullscreen ones), so I suppose they acted like that due to me recording at the same time.

I’ll do some tests with a simple project later, without possible interferences.

I have implemented a PID component in Blueprints, and although I have only used it in very simple scenes, it shouldn’t be an issue for performance.
Acutally, the only term that can have real performance issues is the integral term, as it accumulates error in time and uses that to output a value. That’s why the integral term is always truncated to only keep track of the last few seconds at most.

I would suggest using P and D only, however: unless you have severe asymmetry issues, P should be enough to correct for orientation, and D will dampen and stabilize everything.

Yeah, a simple PID controller in Tick is fine for a ship. If you have hundreds of ships, the difference between blueprint and C++ will start being noticed!