public void InputProcessing_SimulationStep(NeoAxis.Component obj) { var sender = (NeoAxis.Component_InputProcessing)obj; //get access to the ship var ship = sender.Parent; if (ship == null) { return; } //control the ship var body = ship.GetComponent <Component_RigidBody2D>(); if (body != null) { //keyboard //fly front if (sender.IsKeyPressed(EKeys.W) || sender.IsKeyPressed(EKeys.Up) || sender.IsKeyPressed(EKeys.NumPad8)) { var dir = body.TransformV.Rotation.GetForward().ToVector2(); body.ApplyForce(dir * 1.0); } //fly back if (sender.IsKeyPressed(EKeys.S) || sender.IsKeyPressed(EKeys.Down) || sender.IsKeyPressed(EKeys.NumPad2)) { var dir = body.TransformV.Rotation.GetForward().ToVector2(); body.ApplyForce(dir * -1.0); } //turn left if (sender.IsKeyPressed(EKeys.A) || sender.IsKeyPressed(EKeys.Left) || sender.IsKeyPressed(EKeys.NumPad4)) { body.ApplyTorque(1.0); } //turn right if (sender.IsKeyPressed(EKeys.D) || sender.IsKeyPressed(EKeys.Right) || sender.IsKeyPressed(EKeys.NumPad6)) { body.ApplyTorque(-1.0); } //movement by joystick axes if (Math.Abs(sender.JoystickAxes[0]) >= 0.01) { body.ApplyTorque(-sender.JoystickAxes[0]); } if (Math.Abs(sender.JoystickAxes[1]) >= 0.01) { var dir = body.TransformV.Rotation.GetForward().ToVector2(); body.ApplyForce(dir * sender.JoystickAxes[1]); } //JoystickAxes //JoystickButtons //JoystickPOVs //JoystickSliders //IsJoystickButtonPressed //GetJoystickAxis //GetJoystickPOV //GetJoystickSlider } }
public void InputProcessing_SimulationStep(NeoAxis.Component obj) { var sender = (NeoAxis.Component_InputProcessing)obj; //get access to the ship var ship = sender.Parent; if (ship == null) { return; } //control the ship var body = ship.GetComponent <Component_RigidBody2D>(); if (body != null) { //fly front if (sender.IsKeyPressed(EKeys.W) || sender.IsKeyPressed(EKeys.Up)) { var dir = body.TransformV.Rotation.GetForward().ToVector2(); body.ApplyForce(dir * 1.0); } //fly back if (sender.IsKeyPressed(EKeys.S) || sender.IsKeyPressed(EKeys.Down)) { var dir = body.TransformV.Rotation.GetForward().ToVector2(); body.ApplyForce(dir * -1.0); } //turn left if (sender.IsKeyPressed(EKeys.A) || sender.IsKeyPressed(EKeys.Left)) { body.ApplyTorque(1.0); } //turn right if (sender.IsKeyPressed(EKeys.D) || sender.IsKeyPressed(EKeys.Right)) { body.ApplyTorque(-1.0); } } }