Space Engineers

Space Engineers

42 ratings
Subgrid Wheel Controller
2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
557.418 KB
22 Jan, 2020 @ 4:10pm
12 Nov, 2023 @ 6:44am
8 Change Notes ( view )

Subscribe to download
Subgrid Wheel Controller

Description
Script that allows you to control wheels on subgrid from a cockpit, seat or remote using normal controls,
created for making swivel suspensions like this: https://youtu.be/x7hs5V444ew?t=142
But can be used for whatever.

Usage:
Put the script in a PB on your craft, and drive like you normally would.
If there are no wheels on the same grid as cockpit, you cannot use the normal Parking Brake.
Instead, run the PB with the argument "park" to put the script in parking mode.
You can put the PB on an action bar button for this.


There are configurable values at the top of the script:
Controller_Name - Type the name of your Cockpit/seat/remote here, if your craft has more than one.
InvertSteering - Inverts the steering direction if set to true

PowerMod - Modifier for the amount of propulsion power, 1.0 = 100%, the value can be more than 100%!

BrakePowerLimit - The amount of propulsion power the brakes may use (default 100%).
HandBrakeMod - The Handbrake reverses wheels based on their speed, this value dictates how hard.
HandBrakeInt - This dictates how fast the brakes increase in power, the longer time the craft is moving.

SteeringBank - Set to true, to enable banking.
NeutralHeightOff - The susp. offset you want in neutral position
MaxOffset - The max susp. offset you want
MinOffset - The min susp. offset you want
BankMod - Modifier for the banking action, eg. higher values make it bank more at lower speed.
BankGroup - Name if the group of wheels you want to bank, if empty, all wheels will bank



"bugs":
Handbrake will consume power, since it's actually using the motors to hold still rather than braking.
This is because there does not currently seem to be a way to brake motorized wheels via the PB
The handbrake may only slow the craft to a very low speed, but still have the craft moving.
50 Comments
kennet0508 5 Jul @ 7:39am 
Another update:
The automatic parking brake seems to have happend because of mag plates autolock and set to use parking brake, removing that seems to have disabled the constant parking brake, so removing constys airplane parts fixed the error, and toggling off mag plate autolock fixed the automatic parking brake re-applying, but now i got a completely different issue, now it cant see the subgrid wheels, i think im gonna have to get back to this at a later stage in the build process
kennet0508 5 Jul @ 5:53am 
Seems like maybe the modded wheels trigger the parking brake automatically?
kennet0508 5 Jul @ 5:46am 
probably because he's suspension blocks have some greyed out options like steering and propulsion aswell as none of the wheel values can be modified, so somethings acting up
kennet0508 5 Jul @ 5:44am 
ohh nwm, i think i know... its probably modded wheel blocks from consty's aircraft pack, weird that whiplash's script at the moment seems to work fine with it
kennet0508 5 Jul @ 5:42am 
just got an error message:

Parked
Caught exception during execution of script:Object reference not set to an instance of an object.
at Program.WheelHandeler(IMyShipController cockpit, List`1 wheels)
at Program.Main(String argument, UpdateType updateSource)
at Sandbox.Game.Entities.Blocks.MyProgrammableBlock.<>c__DisplayClass42_0.<ExecuteCode>b__0(IMyGridProgram program)
at Sandbox.Game.Entities.Blocks.MyProgrammableBlock.RunSandboxedProgramActionCore(Action`1 action, String& response)

Any clue where i should start looking for cause?
Jack Schitt 10 Jun @ 9:20am 
Checking Code fails.

"Program(116,64): Warning: Field 'Program.vel' is never assigned to, and will always have its default value 0"

Script won't run.
kennet0508 2 May @ 6:54am 
Hey Tekk, Again it cant be said enough how impressive this script is, and the added banking feature is great.

I have another feature update request, its the same i asked last time but ive provided an example of why it would be beneficial. (now with the new tank framework API from Digi, creativity is flowing!)

- https://steamproxy.net/sharedfiles/filedetails/?id=3237591926

The example has my current workaround for getting groups:
have the same script running on multiple programmable blocks with banking enabled, each one with a labeled group, example, programmable block 1, group 1, programmable block 2, group 2 etc.

feature update: Bank groups
Reason:
On custom suspension where you have layers of suspension, having one group of suspensions isnt enough.
suspension group 1 is strength, group 2 is angle, group 3 is wheels on ground. all three needs to move differently to achieve a good bank.
kennet0508 2 May @ 6:54am 
Group 1 needs one neutral height while group 2 needs another while group 3 needs a third

Proposed setup/modification: (mind that im not good at coding but something ish like this?)

//Banking "rolls" the vehicle using suspension offset when turning
//The amount of banking is determined by how fast you are turning, modified by BankMod
bool SteeringBank = true; //Toggles banking the vehicle when turning to alleviate chance of rolling

//copy this part to add more groups:
string BankGroup = "Group 1";
double NeutralHeightOff = -1.5;
double MaxOffset = -0.5;
double MinOffset = -1.5;
double BankMod = -5.0;

//copy this part to add more groups:
string BankGroup = "Group 2";
double NeutralHeightOff = 0.55;
double MaxOffset = 1.3;
double MinOffset = 0.55;
double BankMod = -5.0;
Phooenix 12 Nov, 2023 @ 9:59am 
Yeah i think i modified the script so it did a similar thing
Tekk  [author] 12 Nov, 2023 @ 6:51am 
Rewrote how the script parks and brakes in general.
Instead of applying a force to all wheels based on the speed of the grid, it now applies it based on the rotational speed of each individual wheel.
Added some description to the three modifies for braking that should help fix individual issues.

This should fix the issue of wheels spinning when connected to other grids and parked, and should significantly improve parking brakes on an incline.

As for parking without wheels on the main grid;
You can add the PB to actionbar, and give it the argument "park", pushing this button will now toggle park on/off internally in the script, so it'll work with no wheels on the same grid as cockpit.

Have only tested it with two mid-sized grids, so probably some bugs to iron out, feedback is appreciated :)