Question by
MandyLam24 · Apr 30 at 02:03 PM ·
animationmovement
Input System error
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem;
public class AnimationAndMovementController : MonoBehaviour {
PlayerInput playerInput;
CharacterController characterController;
Animator animator;
Vector2 currentMovementInput;
Vector3 currentMovement;
bool isMovementPressed;
void Awake()
{
playerInput = new PlayerInput();
characterController = GetComponent<CharacterController>();
animator = GetComponent<Animator>();
playerInput.CharacterControls.Move.started += onMovementInput;
playerInput.CharacterControls.Move.canceled += onMovementInput;
playerInput.CharacterControls.Move.performed += onMovementInput;
}
void onMovementInput (InputAction.CallbackContext context)
{
currentMovementInput = context.ReadValue<Vector2>();
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();
}
}
I am following a tutorial on Youtube and the code is the same with the tutorial but it keeps showing this error..may I know what should I do for solving this problem? Thank you for answering my question.
Assets\Scripts\AnimationAndMovementController.cs(54,21): error CS1061: 'PlayerInput' does not contain a definition for 'CharacterControls' and no accessible extension method 'CharacterControls' accepting a first argument of type 'PlayerInput' could be found (are you missing a using directive or an assembly reference?)
Comment
Your answer
