简体   繁体   中英

C# error: 1061 'PlayerLook' does not contain a definition for 'ProcessLook' and no accessible extension method 'ProcessLook'

I am getting a error telling me that 'PlayerLook' does not contain a definition for 'ProcessLook' and no accessible extension method 'ProcessLook' accepting a first argument of type 'PlayerLook' could be found (are you missing a using directive or an assembly reference?). I have retyped the whole script but I'm still getting the same error

here's the code, the error can be found on line (33,14)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class InputManager : MonoBehaviour
{
    private PlayerInput playerInput;
    private PlayerInput.OnFootActions onFoot;

    private PlayerMotor motor;
    private PlayerLook look;
    // Start is called before the first frame update
    void Awake()
    {
        playerInput = new PlayerInput();
        onFoot = playerInput.OnFoot;

        motor = GetComponent<PlayerMotor>();
        look = GetComponent<PlayerLook>();

        onFoot.Jump.performed += ctx => motor.Jump();
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        // tell the playermotor to move using the value from our movement action
        motor.ProcessMove(onFoot.Movement.ReadValue<Vector2>());
    }
    private void LateUpdate()
    {
        look.ProcessLook(onFoot.Look.ReadValue<Vector2>());
    }
    private void OnEnable()
    {
        onFoot.Enable();
    }
    private void OnDisable()
    {
        onFoot.Disable();
    }

}

Tick the "Auto-Save" in the Input Actions tab. This happens because when we added the Look action, it is not updated/saved in the C# file immediately. Thus, the PlayerInput does not recognise "Look" as a method

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM