GetAxis

public static float GetAxis(int playerId, string elementName, VInput.Axis axis);
public static float GetAxis(VPlayer player, string elementName, VInput.Axis axis);

Description

using UnityEngine;
using Volplane;

public class Demo : VolplaneBehaviour
{
    public int playerId;
    public float speed = 10.0f;
    public float rotationSpeed = 100.0f;

    void Update()
    {
        float translation = Input.GetAxis(playerId, "dpad", VInput.Axis.Vertical);
        float rotation = Input.GetAxis(playerId, "dpad", VInput.Axis.Horizontal);

        translation *= speed * Time.deltaTime;
        rotation *= rotationSpeed * Time.deltaTime;

        transform.Translate(0, 0, translation);
        transform.Rotate(0, rotation, 0);
    }
}

Returns the value of the virtual axis defined by axis. This method can be used for d-pad and joystick elements. The value will be in the range -1 to 1.

 

playerId The player identifier.
player A player object.
elementName The name identifier of the input element set in the controller editor.
axis The specified axis using the *VInput.Axis* enumerator.