Space Engineers

Space Engineers

[Script] Gravity Drive
11 Comments
33iRobot33  [author] Mar 14, 2023 @ 12:10pm 
I've uploaded the new version seperately because it works pretty different. There are many new settings at the start of the script and i hope its understandable. Basically the gravity gets stronger the faster the ship gets. I played around with the settings for a while and the autopilot is able to stop correctly but you have to adapt the settings to the ship it is used on. There is still a lot room for improvement and i'm not completely sure if the new approach is better.

Link: https://steamcommunity.com/sharedfiles/filedetails/?id=2946983607
33iRobot33  [author] Mar 14, 2023 @ 8:22am 
I think i found the main reason for the shaking. If the thrusters are too weak for the ship's mass the autopilot / inertia dampeners will use the thruster nearly always at 100%. Since i made the strength of the Gravity Generators dependant on that it doesn't work. I didn't think of that but i guess you never stop learning :D
I have to test a new approach on how to determine the gravity strength especially while braking or maneuvering at low speeds.

I also added the group feature but i'll wait out my tests before i update the script.
Lunatricky Mar 13, 2023 @ 10:17am 
RDav's script uses the standard autopilot so if it works with the remote control it'll work with at least with that script.
And sure lots of scripts use a preset group name you can change in the start of the code so you either use that name or you easily change it there.
33iRobot33  [author] Mar 13, 2023 @ 8:16am 
That could be a promising approach. I'll try integrating it in the script.
Also the group thing is nice and should be very easy to add. I made something like that in another script, i just have to find and copy it :D
What do you think would be the user friendliest concept? Writing the name of your block group in a const string at the start of the code?
I'm gonna test it mainly with the standard autopilot, since im really unexperienced with all the drone scripts.

I'm also enjoying this challenge and maybe we'll get a working script in the end.
Lunatricky Mar 13, 2023 @ 4:11am 
I tried the script with PAM this time and PAM doesn't like it because it tries to fly very close to specific waypoints and the gravity drive I was using was so fast it kept trying to go back and forth in the same point rather than following the set way points. Might be hard to get any gravity drive to work with drone scripts or with the remote control block. I'll keep testing with different scripts and ships to see if I can find one that works well.

Thank you for taking on the challenge it's been fun testing such a cool script!
Lunatricky Mar 13, 2023 @ 4:11am 
I tried the new version and it works great when moving but as you try to stop it keeps jittering and can't stop, I guess the script would need to turn off the grav drive when flying at very slow speeds and let the thrusters stop it, or just use less acceleration on the grav gens the slower it moves, but still use full acceleration to accelerate.
An other thing that could be useful would be the ability to set a group for the grav gens and mass blocks for the drive in case we want the script to ignore other blocks used for different things such as player made weapons or even just a single grav generator to have gravity on the ship.
33iRobot33  [author] Mar 12, 2023 @ 5:27pm 
After some further testing i noticed that the more acceleration the gravity drive provides the harder it gets for the autopilot / inertia dampeners to control the grid. I will think about ways to solve this.
33iRobot33  [author] Mar 12, 2023 @ 4:54pm 
"float gravity = (relativeThrust/Math.Abs(relativeThrust) * 9.81f)" the problem with that is that you can only give full acceleration or none. I don't think the autopilot / drones will work with that. That's why i linked it to the relative thruster strength. I think this should work best for the autopilot. I did some testing with the current autopilot of the Remote Block. It works very well but i should test some more cases and setups. Since i don't know RDav's script i can't really say sth about that.


Thank you very much for the feedback. I'd be glad to hear more tips or your opinion on the changes. Happy engineering :D
33iRobot33  [author] Mar 12, 2023 @ 4:54pm 
I updated the script:

- I deleted the 'divide by generator amount line', it was a remnant of the realistic gravity script that i forgot to remove.

- There is a new setting in the first line of the code "gravityMultiplier". It multiplies the conversion from the relative thrust to gravity. E.g.: Factor 1: 0.2 thrust strength --> 0.2g gravity; Factor 3: 0.2 thrust strength --> 0.6g gravity; etc.

- The mass block(s) get turned off while not used.

- Added more info to the info box
Lunatricky Mar 11, 2023 @ 3:45pm 
I noticed you divide the gravity to put into the generators by the number of generators on line 383 why is that? Won't that make it so the more generators you add the less thrust you get? Also on that line I changed it to float gravity = (relativeThrust/Math.Abs(relativeThrust) * 9.81f); so it only calculates the direction and then returns 1G (max gravity the generator can do in the right direction) and this doesn't work as it makes the ship shake constantly so your approach of get the thrust to gravity seem to be the right way to go. I just need to test it with better scripts for drones or we can wait for the new update and see how it behaves then.
Lunatricky Mar 11, 2023 @ 3:45pm 
I tested it with RDav Fleet Command and it doesn't seem to give much of an impulse. RDav's script uses the remote control block which causes thrusters to go off in all directions in a very inefficient way so I gess that's the problem and not RDav's nor your script per se.
Some improvements I can see would be to turn off the mass blocks when not in use too, not just the grav gens.