Advanced Directional Strafing in BABS

Started by Boba Fett Link, March 31, 2012, 12:32:24 pm

Previous topic - Next topic

Boba Fett Link

March 31, 2012, 12:32:24 pm Last Edit: April 01, 2012, 10:47:09 am by Boba Fett Link
Strafing Direction Buttons


Making a simple strafing system is easy in BABS. A simple conditional branch in a conditional branch is all it takes:
Spoiler: ShowHide
Photo courtesy of Game_Guy


However, what if you want the player to be able to quickly switch strafing directions? This is a more complex system of strafing using four buttons (default arrow keys, but can be changed) which can be pressed to quickly make the player face a specific direction and then lock that direction.

My original design looked a little like this (for only one direction)

Spoiler: ShowHide


However, this setup won't let you move when the arrow key is pressed, because the 'Turn' command keeps the player from moving when it is running. So a more complex system is needed.





Step 1.

First, we need to set up our Common Event. Make the trigger to parallel process. Make a switch that you will turn on at the beginning of the game and name it 'Start'. Set the conditional switch to that trigger.




Step 2.

Next, we need to make it so the player turns in the correct direction when the correct key is pressed. Let's start with the left direction first. Make a conditional branch and select 'script' on the fourth page. Insert the following script:

Input.trigger?(Input::Key['Arrow Left'])


This code makes the conditional branch run when the Left arrow key is pressed. If you want to change the button, replace 'Arrow Left' with the correct code from the Blizz-ABS manual.

Set handling on the conditional branch to none.




Step 3.

Under the conditional branch, create a move route command. Add the command 'Turn Left'.

Now, if you test it now, the player should turn left when the Left arrow key is pressed (make sure you turn on your switch). Copy this conditional branch for all the other directions, but make sure you change the button in the conditional branch and the Move route command.

Here is what your Common event should look like now:

Spoiler: ShowHide



*rest of tutorial coming soon...


This system works well, however, there is one bug. You can't change strafing directions when the player is moving. If anyone has any suggestions on how to fix this, please post it here.
This post will self-destruct in 30 seconds.