_xiaofang/xiaofang/Assets/Script/Character/PlayerMovement_Jpystick.cs
2024-11-12 10:42:00 +08:00

19 lines
487 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement_Jpystick : MonoBehaviour
{
public Joystick joystick; // ½«JoystickÍÏÈë´Ë´¦
public float speed = 5f;
void Update()
{
float horizontal = joystick.Horizontal;
float vertical = joystick.Vertical;
Vector3 direction = new Vector3(horizontal, 0, vertical);
transform.Translate(direction * speed * Time.deltaTime, Space.World);
}
}