<aside> <img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />
Navigation
</aside>
<aside> 💡 While the character is launched, a floating joystick sets the steering. TouchMoveInput implements IMoveInput and the PlayerController passes its value to the active movement behavior.
</aside>
For the aim phase input (drag and timing), see Level Setup.
GetMoveValue(), that returns a Vector2.The joystick base appears where the finger touches the screen and disappears on release. The value is the offset of the finger from the base, divided by the base radius and clamped to 1. Only the first finger steers.
| Field | Description |
|---|---|
| Dead Zone | Values below this threshold read as zero. The rest is rescaled to 0…1. |
| Background | Base circle. Its size is the full travel of the stick. |
| Handle | Knob circle, child of the background. |
GameController enables the input only while the character is launched. It disables the input at the end of the run, so the stick resets.
| Vehicle | Axis |
|---|---|
| Sled, car, wheel | Horizontal (x) |
| Airplane | Vertical (y) for the pitch and horizontal (x) for the bank |
Vector2 move = character.MoveValue;
Create the class. Implement IMoveInput in a MonoBehaviour. Return the steering in the range -1…1 for each axis.
using UnityEngine;
namespace Watermelon
{
public class ButtonsMoveInput : MonoBehaviour, IMoveInput
{
private Vector2 moveValue;
public void SetMove(Vector2 value)
{
moveValue = value;
}
public Vector2 GetMoveValue()
{
return moveValue;
}
}
}
Link it. GameController has the serialized field moveInput of the type TouchMoveInput. It calls character.SetMoveInput(moveInput) in Awake and sets moveInput.enabled at the launch and at the end of the run. Change the field type to your class and assign the new component in the Game scene.
Reset on disable. Set the value to zero in OnDisable, so the vehicle does not keep the last steering after the run.