You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/Joystick Pack_Free/Examples/JoystickPlayerExample.cs

16 lines
482 B
C#

3 months ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JoystickPlayerExample : MonoBehaviour
{
public float speed;
public VariableJoystick variableJoystick;
public Rigidbody rb;
public void FixedUpdate()
{
Vector3 direction = Vector3.forward * variableJoystick.Vertical + Vector3.right * variableJoystick.Horizontal;
rb.AddForce(direction * speed * Time.fixedDeltaTime, ForceMode.VelocityChange);
}
}