I am making an attempt to make an “Goal Mode” in Stride for a third particular person, 2D platformer. The thought is that participant presses (and releases) a button that prompts Goal Mode, and Goal Mode stays on till participant presses the Goal Mode button once more.
For the reason that intention is to be usable on keyboard and controller, I applied the management as a digital button (at present set to proper mouse button and gamepad B), and for the sake of testing I simply have Goal Mode be a debug textual content showing on display that claims “Goal Mode Energetic”.
The issue I’ve encountered is that Goal Mode will solely keep on when one of many buttons is held down, in order quickly because the button is launched Goal Mode turns off, when the intention is for Goal Mode to remain on till one of many related buttons is pressed once more.
What I’ve tried thus far:
- transferring the “If” assertion beginning at “if (aimModeButton == 1)” from
the Replace methodology to the Begin methodology - transferring “bool aimModeActive = false;” into Replace methodology
- including “aimModeActive == false;” to If situation and setting “aimModeActive = !aimModeActive”
- setting “aimModeActive = !aimModeActive” inside If assertion with out altering If situation
I am now at a lack of what to do subsequent, since Stride would not have a devoted “Is Digital Button Pressed” methodology prefer it does with keyboard buttons, and I am pretty new to C# (and programming typically) as is.
Related code under:
personal bool aimModeActive = false;
public override void Begin()
{
Enter.VirtualButtonConfigSet = Enter.VirtualButtonConfigSet ?? new VirtualButtonConfigSet();
var aimMouseRight = new VirtualButtonBinding("Goal Mode", VirtualButton.Mouse.Proper);
var aimGamePadB = new VirtualButtonBinding("Goal Mode", VirtualButton.GamePad.B);
var virtualButtonAimMode = new VirtualButtonConfig
{
aimMouseRight,
aimGamePadB
};
Enter.VirtualButtonConfigSet.Add(virtualButtonAimMode);
}
public override void Replace()
{
{
var aimModeButton = Enter.GetVirtualButton(0, "Goal Mode");
if (aimModeButton == 1)
{
aimModeActive = true;
if (aimModeActive == true)
{
DebugText.Print("Goal Mode Energetic", new Int2(400, 400));
}
}
}
}