Joystick Controlled

Description

The Joystick Controlled behavior will allow you to control and move any physics object using an on screen joystick. If there is no joystick in your scene, the behavior will automatically add a joystick to your Global UI layer (deleting the behavior will not remove the joystick from your scene). This behavior contains predefined properties to make the creation of certain games easier. It's perfect for platformers, and shooters. The Joystick Controlled behavior offers a lot of properties to customize the feel of your game. Try modifying the properties so your game doesn't feel like a generic platformer or shooter. For more advanced and in-depth games, it is recommended to create your own control scheme using the other behaviors.

 

 This behavior will Trigger an event repeatedly while you're moving the joystick in a certain direction.

 

Properties

Triggers Repeatedly on Event

Note: Some of these properties are not available, or behave differently when switching your project to Birds Eye View instead of Side View.

Object A

This is the joystick that will be controlling Object B. It will automatically select a joystick added to your Global UI layer. if there is none, one will be created automatically.

Object B

This is the object you want to control with the joystick. By default the current object is selected, but you can tap the graphic to change it to any other object in your scene. 

Walking Speed

This is how fast the object will move. The default value is 12 m/s.

Air Speed

This is how fast the object will move while it's in the air. Typically while falling from very high platforms. The default value is 12 m/s.

Acceleration Rate

This value determines how long it takes your character to reach full speed when moving. The default value is 100%.

Deceleration Rate

This value determines how long it takes your character to come to a complete stop when you release the joystick. The default value is 100%

Controls Movement

By default this toggle is on. If you turn off the toggle switch, your object will no longer move with the joystick. This is often needed when creating a twin stick shooter, where you want one joystick to move and another to rotate the player.

Invert X

When this toggle switch is on, moving the joystick left causes the object to go right, and moving the joystick right causes the object to go to the left. By default this toggle is off.

Invert Y

When this toggle switch is on, moving the joystick up causes the object to go down, and moving the joystick down causes the object to go to the top. By default this toggle is off.

Controls Rotation

By default this toggle is off. If you turn on the toggle switch, your object will rotate with the direction of the joystick. This is often needed when creating a twin stick shooter, where you want one joystick to move and another to rotate the player.

Lock Rotation

This will prevent your object from rotating. This includes any rotation caused by other objects or physics in your scene. For example, you can turn this on to prevent your character from tipping over. If you enable Controls Rotation, this toggle is not available. By default this toggle is on.

Analog Joystick

When this toggle is on, your joystick is not limited to the standard 8 way movements. You can now control your object with the joystick in more precise movements. This is often needed for action shooters. 

Joystick Up

When this is on, your object can move up. Keep in mind your object will still adhere to the rules of physics. So if there is gravity in your scene your object will not move up.

This toggle will also prevent(or enable) an event triggering when the joystick is moved in the up direction.

Joystick Down

When this is on, your object can move down. Keep in mind your object will still adhere to the rules of physics. So if there is an object in your scene preventing you from moving, you can not move down.

This toggle will also prevent(or enable) an event triggering when the joystick is moved in the down direction.

Joystick Left

When this is on, your object can move in the left direction. Keep in mind your object will still adhere to the rules of physics. So if there is an object in your scene preventing you from moving, you can not move left.

This toggle will also prevent(or enable) an event triggering when the joystick is moved in the left direction.

Joystick Right

When this is on, your object can move towards the right. Keep in mind your object will still adhere to the rules of physics. So if there is an object in your scene preventing you from moving, you can not move in the right direction.

This toggle will also prevent(or enable) an event triggering when the joystick is moved in the right direction.

Play Animations

When this toggle is on, your object will play an animation when the joystick is moved to the specified direction. You must select an animation from the Custom Animations panel.

Custom Animations

On the left panel, you can select animation cycles to play when you move the joystick in the specified direction.

Animation Priority 

On the left Custom Animations panel, you can prioritize your movement animations so it does not conflict with another playing animation. The animation system will play a cycle with a higher priority. So if another animation behavior is interrupting your movement animation, try increasing the priority.

 

Outputs

X

This value indicates how much the joystick has moved in the X axis. Negative numbers indicate the joystick is moving left, positive indicate right. 

Y

This value indicates how much the joystick has moved in the X axis. Negative numbers indicate the joystick is moving down, positive indicate top.

Angle

This outputs the current angle of the joystick.

Object ID

Outputs the object's ID.

 

Examples

If you want to make a platform game like Mario, you can simply add this behavior to your player object, and now it will be a controllable character in your game.

Download Example Project

 

Related

Jump with Button

 

JoystickControlledReference.gif

0 Comments

Article is closed for comments.