44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using static UnityEngine.InputSystem.InputAction;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
using YooAsset;
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
namespace Tuan.GameScripts.Main
|
|
{
|
|
public class ThirdCharacterController : MonoBehaviour
|
|
{
|
|
public CharacterController characterController;
|
|
public Animator animator;
|
|
public Transform forward;
|
|
public Transform model;
|
|
|
|
public float moveSpeed = 5f;
|
|
public float turnSpeed = 10f;
|
|
public float jumpSpeed = 8f;
|
|
public float gravity = 20f;
|
|
public float minCameraDistance = 2f;
|
|
public float maxCameraDistance = 10f;
|
|
public float cameraZoomSpeed = 0.1f;
|
|
|
|
InputActionAsset playerActions;
|
|
Vector2 moveInput;
|
|
|
|
async void Awake()
|
|
{
|
|
await LoadInputActonAsset();
|
|
}
|
|
async UniTask LoadInputActonAsset()
|
|
{
|
|
AssetHandle handle = YooAssets.LoadAssetAsync<InputActionAsset>("PlayerActions");
|
|
await handle.ToUniTask();
|
|
playerActions = handle.AssetObject as InputActionAsset;
|
|
}
|
|
|
|
public void OnMove(CallbackContext context)
|
|
{
|
|
moveInput = context.ReadValue<Vector2>();
|
|
}
|
|
}
|
|
}
|