Diagonal ship controls successfully created via programmable block in se 1
-this is the third post i make about this no mod is needed, only the blow scipt in a programbel block
so what this does is simply to make the gyro spin via the diagonal axis when e and q is pressed
and creates specefic diagonal movement via the below logic as on key pressed now read as 2 keys pressed instead
W → W + D
D → D + S
S → S + A
A → A + W
-you might exprince that you have to place the cockpit at a specific orientation due to the diagonal logic is specifed
--you need to use the crosshair for hyperjump
i have added 2 pics so you can see how i palced the cockpit so it utlize this logic might be a bit hard to see the cockpit as only the door of it is visbel in the front section of this testing ship
to use it you need to place it the edit option of programbel block delete all the text within this option first the only add the contents not the "" clik ok then run
below is scipt "scipt"
"/*
X-VECTOR FULL CONTROL – SE1
W/A/S/D → diagonal thrust
Q/E → diagonal roll
Mouse → normal pitch/yaw
*/
IMyCockpit cockpit;
List<IMyThrust> thrusters = new List<IMyThrust>();
List<IMyGyro> gyros = new List<IMyGyro>();
bool xVectorActive = false;
public Program()
{
Runtime.UpdateFrequency = UpdateFrequency.Update1;
ResetGyros(); // Ensure no lingering overrides
}
public void Main(string argument, UpdateType updateSource)
{
// --- Get controlled cockpit ---
cockpit = GetControlledCockpit();
if (cockpit == null)
{
Cleanup();
return;
}
// --- Collect thrusters ---
thrusters.Clear();
GridTerminalSystem.GetBlocksOfType(thrusters, t => t.CubeGrid == cockpit.CubeGrid);
// --- Collect gyros ---
gyros.Clear();
GridTerminalSystem.GetBlocksOfType(gyros, g => g.CubeGrid == cockpit.CubeGrid);
// --- Diagonal thrust mapping ---
Vector3 move = cockpit.MoveIndicator;
if (move.LengthSquared() < 0.01f)
{
if (xVectorActive)
{
ResetThrusters();
xVectorActive = false;
}
}
else
{
xVectorActive = true;
Vector3D desiredDir = Vector3D.Zero;
// W/A/S/D → diagonal mapping
if (move.Z < -0.1f) desiredDir += cockpit.WorldMatrix.Forward + cockpit.WorldMatrix.Right; // W → W + D
if (move.X > 0.1f) desiredDir += cockpit.WorldMatrix.Right - cockpit.WorldMatrix.Forward; // D → D + S
if (move.Z > 0.1f) desiredDir += -cockpit.WorldMatrix.Forward - cockpit.WorldMatrix.Right; // S → S + A
if (move.X < -0.1f) desiredDir += -cockpit.WorldMatrix.Right + cockpit.WorldMatrix.Forward; // A → A + W
desiredDir.Normalize();
ApplyVectorThrust(desiredDir);
}
// --- Diagonal roll mapping ---
float rollInput = cockpit.RollIndicator; // Q/E input
if (Math.Abs(rollInput) > 0.05f)
{
Vector3D diagonalAxis = (cockpit.WorldMatrix.Forward + cockpit.WorldMatrix.Right);
diagonalAxis.Normalize();
foreach (var g in gyros)
{
g.GyroOverride = true;
g.Pitch = 0f; // Mouse pitch unaffected
g.Yaw = 0f; // Mouse yaw unaffected
g.Roll = rollInput * 100f; // Scale as needed
}
}
else
{
// Release override if no Q/E input
foreach (var g in gyros)
g.GyroOverride = false;
}
}
// ----------------- Helpers -----------------
IMyCockpit GetControlledCockpit()
{
var list = new List<IMyCockpit>();
GridTerminalSystem.GetBlocksOfType(list);
foreach (var c in list)
if (c.IsUnderControl && c.CubeGrid == Me.CubeGrid)
return c;
return null;
}
void ApplyVectorThrust(Vector3D desiredDir)
{
foreach (var t in thrusters)
{
Vector3D thrustDir = t.WorldMatrix.Backward;
double dot = Vector3D.Dot(thrustDir, desiredDir);
t.ThrustOverridePercentage = (dot > 0.6) ? (float)dot : 0f;
}
}
void ResetThrusters()
{
foreach (var t in thrusters)
t.ThrustOverridePercentage = 0f;
}
void ResetGyros()
{
foreach (var g in gyros)
g.GyroOverride = false;
}
void Cleanup()
{
ResetThrusters();
ResetGyros();
}
"
I like this feedback
The current limitation to se1 is the up and down via mouse but SE1 gyros expose only orthogonal control inputs, not torque vectors; diagonal rotational control cannot be implemented without access to angular force or orientation targets
The current limitation to se1 is the up and down via mouse but SE1 gyros expose only orthogonal control inputs, not torque vectors; diagonal rotational control cannot be implemented without access to angular force or orientation targets
Replies have been locked on this page!