Joystick and Button

From Fancade Wiki
Revision as of 13:46, 3 June 2024 by RandomName (talk | contribs) (Added script block images)

with these you can use a joystick and buttons to controls things in your games.

File:Joystick And Button.jpg

You can use several combinations, as shown in the image bellow.

File:JOYBUTONEX.png

But there's a limit to keep in mind, imagine a joystick is worth 2 points, and buttons are 1 point, then the limit is that you can only use up to 4 points. So you can only have:

  • 2 joysticks
  • 1 joystick and 2 buttons
  • 1 to 4 buttons

Joystick

Joystick and Button
Joystick.png
TypeScript block
ColliderNone
FolderControl
Ports
Inputs Before
Outputs Joy Dir
After

Adds joystick(s) in the screen. Unlike most of the blocks in Control tab, Joystick doesn't have any execution (yellow) output wire

File:Joystickwire.png

Output

  • Joy Dir: (Joystick Direction) Outputs joystick movement's direction.

Settings

 * XZ - Outputs XZ vector values perpendicular to camera direction (While assuming that the screen is always facing straight to a certain axis)
 * Screen - Outputs XY vector values regardless of where the camera is facing.

Notes

If you use the **XZ** option, Joystick may not give the right outputs you need, because it only gives values perpendicular to the where the camera is facing. The values will seem normal if the camera is facing in Y-axis upwards or downwards, regardless of angle, but if it's facing sidewards or front and backwards it will only output X-axis value if you're looking at Z-axis and vice versa.

In this case you could instead use the **Screen** option which ignores where the camera is facing. This will help but also there's still one more problem to solve: it only outputs values upwards and sidewards now! Well, the solution is actually pretty simple! Just use rotate vector with **Rotation** input [90, 0, 0].

Uploads/Joystick_Solution.jpg

Button

Joystick and Button
Button.png
TypeScript block
ColliderNone
FolderControl
Ports
Inputs Before
Outputs Button
After

Adds button(s) in the screen.

Output

  • Button: Executes when the button display is pressed.

Settings

 * Button - displays the button as a circular button
 * Direction - displays the button as a directional arrow

Setting the display to "Direction" mode results in the following:

  • 1 button - one button is displayed as arrow pointing up

Uploads/Up_Front.jpg

  • 2 buttons - two buttons are displayed as arrows facing left and right respectively.

Uploads/2-Sides.jpg

  • 3 buttons - three buttons are displayed as arrows facing left, right and up respectively.

Uploads/Side-Up.jpg

  • 4 buttons - four buttons are displayed as arrows facing left, right, down and up respectively.

Uploads/All_four.jpg