Я не совсем уверен, что делать.
Я очень новичок в Unity и C# Sharp, так что, может быть, я не вижу никакого смысла?
ну, вот код...
Код: Выделить всё
using System.Collections;
using System.Collections.Generic;
using static System.Numerics.Vector3;
using UnityEngine;
public class AnimationAndMovementController : MonoBehaviour
{
PlayerInput playerInput;
CharacterController characterController;
Vector2 currentMovementInput;
Vector3 currentMovement;
bool isMovementPressed;
void Awake()
{
playerInput = new PlayerInput();
characterController = GetComponent();
playerInput.CharacterControls.Move.started += onMovementInput;
playerInput.CharacterControls.Move.canceled += onMovementInput;
playerInput.CharacterControls.Move.performed += onMovementInput;
}
void onMovementInput (InputAction.CallbackContext context)
{
currentMovementInput = context.ReadValue();
currentMovement.x = currentMovementInput.x;
currentMovement.z = currentMovementInput.y;
isMovementPressed = currentMovementInput.x != 0 || currentMovementInput.y != 0;
}
// Update is called once per frame
void Update()
{
characterController.Move(currentMovement * Time.deltaTime);
}
void OnEnable()
{
playerInput.CharacterControls.Enable();
}
void OnDisable()
{
playerInput.CharacterControls.Disable();
}
}
Подробнее здесь: https://stackoverflow.com/questions/734 ... t-be-found
Мобильная версия