ACM - Advanced Controls Mod [Besiege v0.45]

Lench

Active Member
Works like a charm, thanks. I suspect this will be a must have for multiplayer battles once multiverse comes out. Would be great if you could make that a standard controller axis in a future update, with a sensitivity slider etc.
I used my mouse driver to map LMB to "C" and another mouse button to LMB. Not ideal, but it works for me.
Do you know a way to switch to a zoomed camera block while a button or trigger is held down and switch back to the original camera block when released?
I suppose there's a way to script it, but can't give you the exact implementation from the top of my head. Not sure if I even wrote the API for the camera block. You're welcome to join us in Besiege Discord here https://discord.gg/33WPYEP and I'll see if we can figure something out.
 
I've been tinkering with my atan2 directional controls and added another input to allow rotation of the machine with the same steering system. I have 8 wheels in a compass layout connected to a steering block each.
I need two custom axis, one for wheel speed [0, 1] and one for stering block angle [-1, 1] which equals [-180°; 180°]

I use input from
Left Y (+forwards/-backwards)
Left X (-left/+right)
Right X (-turn left/+ turn right)
α (Direction the wheel needs to face in order for the machine to turn right. This variable is different for each wheel. It is the direction for the Right X vector)
Code:
α for each wheel
                   North wheel 1/2 pi
       NW wheel 1/4 pi    NE wheel 3/4 pi
West wheel: 0                          East wheel pi
       SW wheel: -1/4 pi      SE wheel: -3/4 pi
                   South wheel: -1/2 pi

Here's the maths:
First I convert polar vector {Right X, α} into a carthesian vector {Xr, Yr}.
Code:
Xr=Right X*cos α
Yr=Right X*sin α
Then I can add that vector to the left stick's vector {Left X, Left Y} to make the resulting direction vector {X, Y}.
Code:
X=Left X+Xr
Y=Left Y+Yr
For the wheel speed {Xs, Ys}, I multiply the two vectors with 0.7 and 0.5 respectively before adding them so they are weighted torwards speed and Xs and Ys stay in the range of [0,1]
Code:
Xs=0.7*Left X+0.3*Xr
Ys=0.7*Left Y+0.3*Yr
Now I convert into polar coordinates again. For the steering block angle I use atan2. To comply with the [-1,1] range I divide by pi.
Code:
steering block angle = atan2(X, Y)/pi
For the wheel speed I use pythagoras.
Code:
wheel speed = sqrt(Xs²+Ys²)
So basically, the two formulas are
Code:
wheel speed = sqrt((0.7*Left X+0.3*Right X*cos α)²+(0.7*Left Y+0.3*Right X*sin α)²)
steering block angle = atan2(Left X+Right X*cos α, Left Y+Right X*sin α)/pi
with α being specific to each wheel

here's what I got:

init code
Code:
from math import *
LeftX = AdvancedControls.GetAxis("Left X")
LeftY = AdvancedControls.GetAxis("Left Y")
RightX = AdvancedControls.GetAxis("Right X")
update code for the wheels
Code:
sqrt(
pow((
  0.7*LeftX.OutputValue+0.3*RightX.OutputValue*cos(alpha)
),2)
+
pow((
  0.7*LeftY.OutputValue+0.3*RightX.OutputValue*sin(alpha)
),2)
)
update code for the steering blocks
Code:
atan2(
LeftX.OutputValue+RightX.OutputValue*cos(alpha),
LeftY.OutputValue+RightX.OutputValue*sin(alpha)
)/pi
Edit: I didn't get the sin and cos functions to work. So in the code above I replaced them with the numeric values.
Code:
Wheel  cos(α)  sin(α)
N      1       0
NE     0.707  -0.707
E      0      -1
SE    -0.707  -0.707
S     -1       0
SW    -0.707   0.707
W      0       1
NW     0.707   0.707
It works now, I now have a first person shooter control scheme that is somewhat stable. It is still hard to actually track targets, even after I replaced the right stick with my mouse. But it corners better than sleds and hovers because it can drift like a car whereas sleds and hovers have to be manually decelerated in the old direction and accelerated in the new one.

Next project: Third person shooter style intelligent controls with the bot's facing trying to match the Left stick's direction and a turret that tries to match the camera's facing, because right now my car and therefore my camera gets knocked around too much by small bumps to have the camera follow the bot instead of the other way round. I really would like this control scheme to be usable in pvp, although I wonder how pvp will be regulated. Would scripting be even allowed at all? [Edit: Von stated that mods will probably still work once updated for the player who has them installed, and in another note that every player needs to have them installed. We'll see what will be the case for ACM]
 
Last edited:

Sanpyr

Active Member
There seems to be a issue with mouse controls:
so when I map a block (in this circumstance, I used a steering hinge) to mouse controls, but if my mouse is in the center of the screen in the axis it is controlled by when I click play, sometimes it doesn't really move. it will wriggle a few degrees sometimes, and sometimes it will unstick itself, but it doesn't really move, there isn't any console errors either. otherwise, the mod is amazing, thanks! :)

EDIT: the problem seems to be in the Angle option, if I bind a steering hinge to input or rotation speed it works fine
 
Last edited:
I got a problem with my machine not loading the controls when I load the machine. The control scripts stay, but I have to manually reassign them to every block. The console says
[ACM]: Error loading machine's controls:
InvalidCastException: Cannot cast from source type to destination type.
Any ideas how to fix this?
Edit: fixed in new version

Besides, I improved my atan2 steering by getting rid of turning the machine and instead turning wheels individually so they point in the direction of my turret and camera. I also converted back to keyboard/mouse for precise mouse aiming.

Wheels (input):
initialisation code:
Code:
from math import *
LeftX = AdvancedControls.GetAxis("Keys GJ") #these are custom key axis you have to set up
LeftY = AdvancedControls.GetAxis("Keys YH")
Boost = AdvancedControls.GetAxis("Right Alt")
update code
Code:
max(
abs(LeftX.OutputValue),
abs(LeftY.OutputValue)
)/3
+Boost.OutputValue*2/3 #hold alt to go 3x as fast
I put wheel speed at 7 and put opposing steering blocks with the same code to avoid wheelies

Steering block 1 (angle):
initialisation code:
Code:
from math import *
LeftX = AdvancedControls.GetAxis("Keys GJ")
LeftY = AdvancedControls.GetAxis("Keys YH")
update code
Code:
atan2(
LeftX.OutputValue,
LeftY.OutputValue
)/pi
Steering block 2, connected to Steering block 1, (input):
update code
Code:
Input.GetAxis("Mouse X")/10 #divide by 10 so quick movements won't be capped out by the +-1 range
Turret in the center with a camera block and Mouse X input. All steering block speed 8.

I have to make a video of this someday. This is awesome.
 
Last edited:
Does the mod work with the new native modloader? If not, do you have any plans to port it to the Steam Workshop? I need it so desperately :D

EDIT: I tried to build the mod according to the new structure manually and, apparently, the mod uses some System.Reflection features which are forbidden in the new modloader so it doesn't work without modifying the actual code.
 
Last edited:

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
As mentioned in your edit, it probably won't work without reflection
 
Does somebody know an alternative for the mod? I don't even need an interface but only a possibility to controll power or angle of parts while the game is running.
 
Top