Space Engineers

Space Engineers

Subgrid Wheel Controller
52 条留言
Grebanton1234 6 月 27 日 上午 11:48 
Hey there, may I use your script for the current research bunker competition? I think legally I have to ask you for permission because I think by submitting the build I give Keen the right to use it how they want to.
Standard Squid 2024 年 10 月 26 日 下午 1:27 
@Jack Schitt I am having the exact same problem. It was working perfectly last night then suddenly broke
kennet0508 2024 年 7 月 5 日 上午 7:39 
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 2024 年 7 月 5 日 上午 5:53 
Seems like maybe the modded wheels trigger the parking brake automatically?
kennet0508 2024 年 7 月 5 日 上午 5:46 
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 2024 年 7 月 5 日 上午 5:44 
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 2024 年 7 月 5 日 上午 5:42 
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 2024 年 6 月 10 日 上午 9:20 
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 2024 年 5 月 2 日 上午 6:54 
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://psteamcommunity.yuanyoumao.com/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 2024 年 5 月 2 日 上午 6:54 
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 2023 年 11 月 12 日 上午 9:59 
Yeah i think i modified the script so it did a similar thing
Tekk  [作者] 2023 年 11 月 12 日 上午 6:51 
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 :)
Phooenix 2023 年 11 月 12 日 上午 3:39 
Yeah i got it to work but can't remember how xD (the cockpit was on a large piston and a hinge, lowered to allow entrance and goes up and out to give better view)
kennet0508 2023 年 11 月 11 日 下午 5:54 
@Phoenix, parking brake only works if theres a wheel suspension on the same grid as you cockpit and both that suspension and the cockpit needs to have parking brake enabled.
@waddles, i would probably group and turn wheels on/off with a button if parking brake doesnt fix it
Waddles 2023 年 5 月 19 日 上午 11:10 
whenever my rover is hooked up to a connector to charge the wheels spin on their own, is there a fix for this? it seems to be connected to the brake prop override
Phooenix 2023 年 5 月 9 日 上午 9:10 
Hmm okey now today it worked, wierd. However the parking brake doesn't work, not even a little like in description, will look around and see if i can fix it. :)
Phooenix 2023 年 5 月 9 日 上午 8:34 
Tekk, that's what i was doing. I only have one controller, maybe i was explaining badly. I meant that I tried both changing the name manually and also allowing it to default to the first it founds ( the only one) and it didn't work any time. And i did try both of these solutions for each of the control seat, cockpit and industrial cockpit.
Tekk  [作者] 2023 年 5 月 8 日 下午 12:18 
It should work with all controllers; It sounds like you haven't changed the "Controller_Name" in the script and it's defaulting to the first it finds, if you have more than one on your craft, that may not be the one you're intending. Keep in mind all seats/cockpits/remotes count as ship controllers.
Phooenix 2023 年 5 月 7 日 下午 6:55 
Doesn't seem to work, tried both with cockpit and control seat and industrial cockpit, it compiled fine but said "found no cockpit, using control seat instead" and the same for the others, then i tried manually changing the name to the different cockpits, it compiled fine but didn't work. The cockpit/control seat is on a sub sub subobject, (a hinge connected to a piston connected to a hinge that's connected to the control object, It shouldn't matter because it can still find it but i thought i should mention it anyways.
kennet0508 2023 年 2 月 14 日 下午 3:37 
Wow, this is some next level mind blowing stuff!
after initial testing there are a couple of thing to point out:

- Sometimes turning doesnt trigger enough roll to give "enough" banking", this seems to be caued by counterforces from high weight/speed when turning, this is also observed if the wheels loose ground contact and looses its turn momentun. this resets the banking angle adding to the external force, which is scary in a tight turn.

- Banking engages after the rover starts turning and wheels in SE takes time from button press before engaging into a turn (amplified at higher speeds), it feels like the roll engages late and isnt "tight" when needed

Would there be a way for button inputs to engage roll faster?
Example: If player press button "D", script initiates player driven max banking, Player releases D, script reverts to calculating y axis roll? (the way the script already works, it keeps the bank for the remainder of the turn after release and reverts smoothly)
kennet0508 2023 年 2 月 14 日 下午 2:35 
yeah. i tried setting it higher, anything above 25 = twitching if strength is set high
Tekk  [作者] 2023 年 2 月 14 日 下午 2:06 
1: Done.
2: Considered it, felt it got too convoluted.
Banking is done by how fast the vehicle rotates around it's own Y-axis, in Radians/sec.
eg. if you rotate 90 degrees in one second, you're rotating at a rate of +pi/4 radians per second.
That's roughly 0.79, making a BankMod=5 give you an offset of around +3.9 (or whatever your upper limit is. Turning 90 degrees in 10 seconds would give you +0.39 offset

Felt it easier to leave it as a "If it's not banking enough, raise it" sort of value :p
kennet0508 2023 年 2 月 14 日 下午 1:33 
This is so far pretty damn Epic!

two things:
1, is there a way to make it groupable? example: only wheel suspensions in group "banking" is applied
Reasoning is that i use a lot off weird suspension tricks, like having large grid 1x1 as springs and 5x5 small wheels on hinges, in that case i would only want the 1x1 spring system to bank the rover, not the small grid 5x5 wheel as they would only serve to lower ground clearance risking voxel collsion

2. add the min/max values in the readme section, BankMod 5 doesnt give much information, does it go to 10? 100? 1000? 1000000?
example:
double BankMod = 5; //Modifies how strong the banks is.(0<->100, default = 5)
Strong Hoov ✅ 2023 年 2 月 13 日 上午 11:53 
Nice!!
kennet0508 2023 年 2 月 13 日 上午 11:50 
Cant wait, imma test it out asap!
Tekk  [作者] 2023 年 2 月 13 日 上午 10:08 
Cool idea, it is done. (dunno how fast steam updates)

Added a twist tho; the amount of banking is dependent on how fast the vehicle is turning, instead of a static amount for any turn, I think that makes sense, and it looks cool when driving slalom!

For now, the settings for it is at the top of the script with the others, having added the following:
SteeringBank - Set to true, to enable banking. (false by default)
NeutralHeightOff - The susp. offset you want in neutral position (0 by default)
MaxOffset - The max susp. offset you want (1.3 by default)
MinOffset - The min susp. offset you want (-1.5 by default)
BankMod - Modifier for the banking action, eg. higher values make it bank more at lower speed. (5 by default)

Ran some tests but may have missed something, so feedback would be nice.

If it's not how you imagined or you have an idea of a better way for it to behave, do tell :)
kennet0508 2023 年 2 月 12 日 下午 11:03 
Hey Tekk

I have a feature whish for your script.
(Picture for relevance - https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=2930053454)

Would you be willing to ammend/add a function, that would allow the suspension to bank into turns? a type of "Active Body Control" or anti roll? (or perhaps have it as a function in a separate script?)

A function, that when you steer left or right (A/D) the wheel suspension height offset is altered to offset potential roll to custom amount

It would be ofc be off by default, and could be enabled in custom data to maintain the simplicity of your script as is.

Im not a coder so i wouldnt even know where to start, i havent seen anyone make something like this, and this is something im really missing from a lot of my builds. and perhaps for many others
Tekk  [作者] 2022 年 4 月 29 日 下午 1:54 
Sure, you can do that :)
It will only consume power when standing still, when park/handbrake is actually enabled.
If you used a piston + gear instead, you could just avoid putting the vehicle in park, and the motors wouldn't consume power.
fenlander 2022 年 4 月 29 日 下午 1:50 
To park the vehicle without consuming power can you put a landing gear on a piston? Once extended switch off the piston. The gear doesn't need power.
Tekk  [作者] 2022 年 4 月 14 日 下午 7:09 
OBS: Also fixed the inverted steering, and added a toggle at the top of the script to invert steering if wanted.
Tekk  [作者] 2022 年 4 月 14 日 下午 6:59 
Hey people, just did a bit of an overhaul on the script:

- Improved how the script recognizes the center of the craft, so wheels should now be turning in the right direction, even if the controller is not at the center of the craft!

- The script now registers "parking" and will brake accordingly, additionally the script can be run with the argument Park to toggle an internal parking brake on/off, in case the game won't let you use parking or handbrake.

- Changed how the parking brake works, it's not perfect, but it should work a lot better now (Check description for the relevant info if you want to modify braking behavior)

- Realized that a script can set Propulsion Override (way) beyond 100%, so you are now able to set how much propulsion is applied through the variable PowerMod .

- The script will now tell you if your desired cockpit/seat/remote was not found and that another one has been chosen, along with which has been chosen.
Tekk  [作者] 2022 年 3 月 21 日 下午 4:40 
Either I am missing something, or keen isn't prioritizing keeping scripting up to date with features.

I don't know of a way to access Parking, I can only "see" handbrake, so that's the only one the script reacts to :/
Juntao 2022 年 3 月 21 日 下午 4:36 
great script, but does anyone know how to add wheel parking brakes?
Turret problems 2021 年 7 月 12 日 下午 4:13 
Excellent, thank you!
:DS2_Marker: :selike:
Tekk  [作者] 2021 年 7 月 12 日 下午 12:53 
@Turret Problems
Go for it :)
Turret problems 2021 年 7 月 12 日 上午 8:05 
Ive made a modification for this script to allow a reference direction, in case you are driving from a manned turret for example, Could I have permission to upload it and link back to this one? it also includes the steering fix
Spice 2021 年 4 月 8 日 上午 4:37 
Easy inverted steering fix for this script "turner = cockpit.MoveIndicator.X;" becomes "turner = cockpit.MoveIndicator.X * -1;" just invert X and you are fine. Great script. Good for a 27k ton planet-hauler.
ramphaleom 2020 年 9 月 25 日 下午 10:16 
super scripts . nice script :steamhappy:, Merci bcp :)
dlouhynohyzadnejmidget 2020 年 8 月 29 日 上午 4:44 
how do i paste the script into the pb? i mean where is the script, and wherre do i put it in?
Mr.Pig 2020 年 8 月 24 日 下午 5:52 
ill have to take a look.
Tekk  [作者] 2020 年 8 月 24 日 上午 5:18 
@Gunnerman4581
Is handbrake on by any chance?
There doesn't seem to be a way to braking to the wheels using script, so i'm doing it using power instead.

@Rabenschild
I can add that, assuming the ownership works atm
Mr.Pig 2020 年 8 月 20 日 下午 4:24 
im having a problem where the script is taking over propulsion and keeps increasing it to -0.2 or higher. anyone know how to fix this?
Rabenschild 2020 年 4 月 25 日 上午 7:11 
I know you are having trouble with the ownership of the script, but is there a way to make it so the script only takes specific wheels or that you can exclude wheels? I am running into the problem that some wheels i do not want to be moving are reacting to the script.
keyofrage yt 2020 年 2 月 11 日 上午 5:14 
kk thx
Tekk  [作者] 2020 年 2 月 10 日 下午 1:03 
Right.. So, i've somehow lost ownership of the script, i guess? I am not allowed to replace or publish, and my script has in my game been split into a local version (which won't publish) and a workshop version (where i can't do either)...So i guess i'm not updating this one.

**TO FIX INVERTED STEERING**

Look for:
"if (relPos.Z < 0) { turner = -turner; }"
at the bottom of the script and change it to
"if (relPos.Z > 0) { turner = -turner; }"

Just flip the "<"

That should fix it
keyofrage yt 2020 年 2 月 10 日 下午 12:37 
i tried that but the rotors stoped moving alltogether
Tekk  [作者] 2020 年 2 月 10 日 上午 11:59 
Great!
Personally i limit the rotors to +/- 45 degrees, usually prevents then from gettint too close to vertical and still allows for enough rotation to not be an issue while driving.
maybe reduce wheel power as well.

I've tought about putting a torsion spring kinda deal in to make the rotor go towards a neutral position, but fear it may cause issues in some use cases.
keyofrage yt 2020 年 2 月 10 日 上午 11:34 
thx any way
allso how do i prevent the rotor from fliping over cause i had it like 2 rotors on each side with 2 wheels each and for some reason while moveing they have a high chance of fliping is it to do with the weight
keyofrage yt 2020 年 2 月 10 日 上午 11:32 
i realised that about a hour after and i feel like a moron
Tekk  [作者] 2020 年 2 月 10 日 上午 11:09 
It's inverted because i had my wheels upside-down when i was testing it :p

For now, tick off "invert steering" on the wheels, gonna upload a fixed version within the hour