Space Engineers

Space Engineers

Realistic Thrusters (offset forces, NPCs unaffected)
Engi 9 Feb, 2016 @ 6:13pm
FLY-BY-WIRE version of Realistic Thrusters Mod
I posted this in the comments but realized this may be a better place to discuss.

Is it possible to make a mod very similar to this one except that it has a "fly by wire" system that compensates for the lack of symetry in thrust by throttling some thrusters in order to maintain the desired direction of flight? This way a none sysmetrical setup will still fly straight but it will have less thrust in the directions that are not symetrical because some of those thrusters are being throttled in order to maintain straight movement. So the computer adjusts the thrust in order to do what you want, but at the cost of total thrust. So ships that have symetrical thrust will have their full thrust and non symetrical thruster setups will have less thrust since some are throttled. Also, when a ship is damaged, it can still be flown straight (depending on the extent of damage of course) but will have reduced performance since the computer will try to give the desired direction of flight but will have to compensate by throttling as best as it can.

Obviously in some setups it will not be able to compensate. For example a single thruster in one direction that is not lined up exactly with the center of mass. Or two thrusters in one direction that are not on either side of the center of mass and lined up with it exactly in a line, Thruster-CoM-Thruster (symetrical in one axis).
< >
Showing 1-12 of 12 comments
Knsgf 10 Feb, 2016 @ 12:31am 
Such a mod needs to distinguish between rotation induced by asymmetrical thrust and turning commanded by the player. Because mod API doesn't provide player input, implementing a proper engine control unit isn't possible right now without access to the source.
Last edited by Knsgf; 8 Apr, 2016 @ 10:34am
Engi 10 Feb, 2016 @ 7:40am 
What if it is a one shot thing where you run the script and it calculates the required thruster output for that current ship configuration in order to fly straight and saves it? Then if the ship is modified or damaged you run it again and it calculates new thruster outputs and saves those. Can a script determine thruster block placement vs. CoM? Calculating required forces should be easy. Then can the script somehow reduce the max thruster output of individual thrusters to maintain straight flight so that the next time and the times after when a directional key is pressed the thrusters can only output what the script calculated last. This way it does not have to differentiate between rotation by command or by asymmetrical thrust as it is not doing that. Calculations where made by block position and values set until they are calculated again and set.

Or if thruster output cannot be set for use with directional keys, have it calculate the required gyro rotation in order to fly straight and have the gyros override while directional keys are pressed in order to fly straight.
Last edited by Engi; 10 Feb, 2016 @ 7:46am
Engi 9 Apr, 2016 @ 9:27am 
Originally posted by Knsgf:
Such a mod needs to distinguish between rotation induced by asymmetrical thrust and turning commanded by the player. Because mod API doesn't provide player input, implementing a proper engine control unit isn't possible right now without access to the source.
did something change in that now we can maybe do this?
Majca 31 May, 2016 @ 5:21am 
This would be really great... :)
PeterRabbit 22 Jul, 2017 @ 5:26pm 
Originally posted by KC Pilot:
Originally posted by Knsgf:
Such a mod needs to distinguish between rotation induced by asymmetrical thrust and turning commanded by the player. Because mod API doesn't provide player input, implementing a proper engine control unit isn't possible right now without access to the source.
did something change in that now we can maybe do this?
Yes! Scripts can read the desired rotation from the player and autopilot and use it to control the ship.
https://github.com/KeenSoftwareHouse/SpaceEngineers/blob/master/Sources/Sandbox.Common/ModAPI/Ingame/IMyShipController.cs#L151-L154
Last edited by PeterRabbit; 22 Jul, 2017 @ 5:26pm
Knsgf 23 Jul, 2017 @ 12:51am 
Originally posted by PeterRabbit:
Originally posted by KC Pilot:
did something change in that now we can maybe do this?
Yes! Scripts can read the desired rotation from the player and autopilot and use it to control the ship.
Small correction about the autopilot: you have absolutely no control over thrusters when it's active. So while such script can read autopilot input, it can't do anything with it.
PeterRabbit 23 Jul, 2017 @ 5:28am 
Originally posted by Knsgf:
Originally posted by PeterRabbit:
Yes! Scripts can read the desired rotation from the player and autopilot and use it to control the ship.
Small correction about the autopilot: you have absolutely no control over thrusters when it's active. So while such script can read autopilot input, it can't do anything with it.
Oh, damn. Still, for player controlled ships it is fantastic, and you can still write your own autopilot script that uses the camera to avoid obstacles. It would be nice to get a mod that modifies stock autopilot to not override overridden thrusters though.
Last edited by PeterRabbit; 23 Jul, 2017 @ 5:32am
nebelph 13 Jan, 2022 @ 10:24am 
Apologies for reviving a dead discussion, but it's gotten me thinking and I wanted to get those thoughts out:

Originally posted by Engi:
What if it is a one shot thing where you run the script and it calculates the required thruster output for that current ship configuration in order to fly straight and saves it? Then if the ship is modified or damaged you run it again and it calculates new thruster outputs and saves those. Can a script determine thruster block placement vs. CoM? Calculating required forces should be easy. Then can the script somehow reduce the max thruster output of individual thrusters to maintain straight flight so that the next time and the times after when a directional key is pressed the thrusters can only output what the script calculated last. This way it does not have to differentiate between rotation by command or by asymmetrical thrust as it is not doing that. Calculations where made by block position and values set until they are calculated again and set.

This is exactly how I'd do it if I only knew how. It seems like the best way to get the real physics and engineering challenges whilst keeping flight accessible to people who aren't really engineers and without needing constant re-processing. Sadly, I can't find a script that does it to go with this mod.

Ideally it would be possible without a script. I'm guessing a mod could add sliders to the control panel for each thruster that were it's individual thrust limiters for every direction (12 sliders per thruster, I know, but you could make them hide-able or dynamically only show the ones for the 6 directions that apply to that thruster, plus balanced designs wouldn't need much work anyway). A person could then set the profiles manually for fun or to achieve deliberately interesting flight paths (haywire decoy rockets?). Using the script would just calculate the best settings and apply them to the sliders for you. The only real complication is when you try to move in multiple directions that use the same thruster at the same time (again, up to 6 possible). The game would need to be able to scale back the thrust of every thruster according to its profile per direction so that none was needed for more than 100% of its max output. The easiest solution would probably just be to divide every active thruster's settings by the number of directions being accelerated in.

I know adjusting the direction profiles more intelligently when moving in multiple directions at once could theoretically squeeze a little more power out (the more unbalanced the design, the more this is true), but that requires more real-time processing that I don't think is worth it. A person could always fall back on the manual settings method to squeeze those extra bits of thrust out of their design if it's unbalanced enough to benefit from them.

Much the same logic could be applied to using gyros to counter some rotation from thrusters and allow them to push harder, though thankfully there's fewer directions per gyro. However, this could lead to inconsistent steering, so you'd need to be able to exclude some or all gyros when running the calibration. Easiest thing would probably just to have it so that any gyro (or thruster for that matter) that's turned off during calibration is excluded from the calculations and doesn't get its settings changed.

If you allow a script to remember the settings that it created and re-apply them without recalibrating, you could have multiple PBs where the script was run under different original conditions (full cargo, empty cargo, some thrusters turned off) so that you have multiple prepared profiles to load for predictable changes like cargo level or changing atmosphere.

This would all also be interesting in battles because it would mean when you lose some thrust or mass, your control starts to drift until you can re-run the script to compensate for the damage. Not only is that thematic, but it would add a new level of tactics to targeting that wasn't just "which enemy systems do I want to stop working first."

Because this method balances the actual thrust of the ship, any autopilot program should still be able to fly it (until it took damage, though seeing the autopilot fail to fly straight because of damage actually makes sense). NPC ships could be allowed to use the vanilla SE cheat system, but anyone writing an AI to work with this script would just need to incorporate the same calibration process that's in the PB script so that the AI can recalibrate their ship too. Then they'd just need to be told to run that process when they spawn and again every so often if their mass is changing. They wouldn't need the ability to remember and apply old profiles.

So, those are my thoughts. I guess let me know if there's a mod out there that does this. All the ones that I've seen either don't tackle this problem (so you just have to build perfectly balanced) or do it with intensive real-time processing instead of one-off calibrations.
Erikan39 27 Feb, 2022 @ 5:05am 
You could disable thruster input on a cockpit and use the Control Module mod to get wasd input instead and use thruster overrides to control then
And use them to spin the ship too if you disable gyros and get mouse input
Erikan39 3 Mar, 2022 @ 7:42pm 
Working on a script for this right now
Mateus 5 Jul, 2022 @ 5:07pm 
i'm curious, someone has an update about something similar to the original ideia ?
CTH2004 26 Dec, 2022 @ 1:10pm 
Originally posted by ComputerErika:
Working on a script for this right now
how's it doin?
< >
Showing 1-12 of 12 comments
Per page: 1530 50