Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug Error CS1061

Discussion in 'Scripting' started by TrexMatrix, Sep 9, 2023.

  1. TrexMatrix

    TrexMatrix

    Joined:
    Aug 8, 2023
    Posts:
    39
    yo i got these 2 errors idk how to fix them
    Assets\Scripts\InputHandler.cs(92,40): error CS1061: 'PlayerControls.PlayerActionsActions' does not contain a definition for 'RB' and no accessible extension method 'RB' accepting a first argument of type 'PlayerControls.PlayerActionsActions' could be found (are you missing a using directive or an assembly reference?)

    Assets\Scripts\InputHandler.cs(93,40): error CS1061: 'PlayerControls.PlayerActionsActions' does not contain a definition for 'RT' and no accessible extension method 'RT' accepting a first argument of type 'PlayerControls.PlayerActionsActions' could be found (are you missing a using directive or an assembly reference?)

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. namespace HR
    7. {
    8.     public class InputHandler : MonoBehaviour
    9.     {
    10.         public float horizontal;
    11.         public float vertical;
    12.         public float moveAmount;
    13.         public float mouseX;
    14.         public float mouseY;
    15.  
    16.         public bool b_Input;
    17.         public bool rb_Input;
    18.         public bool rt_Input;
    19.  
    20.         public bool rollFlag;
    21.         public bool sprintFlag;
    22.         public float rollInputTimer;
    23.  
    24.         PlayerControls inputActions;
    25.         PlayerAttacker playerAttacker;
    26.         PlayerInventory playerInventory;
    27.  
    28.         Vector2 movementInput;
    29.         Vector2 cameraInput;
    30.  
    31.         private void Awake()
    32.         {
    33.             playerAttacker = GetComponent<PlayerAttacker>();
    34.             playerInventory = GetComponent<PlayerInventory>();
    35.         }
    36.  
    37.         public void OnEnable()
    38.         {
    39.             if (inputActions == null)
    40.             {
    41.                 inputActions = new PlayerControls();
    42.                 inputActions.PlayerMovement.Movement.performed += inputActions => movementInput = inputActions.ReadValue<Vector2>();
    43.                 inputActions.PlayerMovement.Camera.performed += i => cameraInput = i.ReadValue<Vector2>();
    44.             }
    45.  
    46.             inputActions.Enable();
    47.         }
    48.  
    49.         private void OnDisable()
    50.         {
    51.             inputActions.Disable();
    52.         }
    53.  
    54.         public void TickInput(float delta)
    55.         {
    56.             MoveInput(delta);
    57.             HandleRollInput(delta);
    58.             HandleAttackInput(delta);
    59.         }
    60.  
    61.         private void MoveInput(float delta)
    62.         {
    63.             horizontal = movementInput.x;
    64.             vertical = movementInput.y;
    65.             moveAmount = Mathf.Clamp01(Mathf.Abs(horizontal) + Mathf.Abs(vertical));
    66.             mouseX = cameraInput.x;
    67.             mouseY = cameraInput.y;
    68.         }
    69.  
    70.         private void HandleRollInput(float delta)
    71.         {
    72.             b_Input = inputActions.PlayerActions.Roll.phase == UnityEngine.InputSystem.InputActionPhase.Performed;
    73.            
    74.             if (b_Input)
    75.             {
    76.                 rollInputTimer += delta;
    77.                 sprintFlag = true;
    78.             }
    79.             else
    80.             {
    81.                 if(rollInputTimer > 0 && rollInputTimer < 0.5f)
    82.                 {
    83.                     sprintFlag = false;
    84.                     rollFlag = true;
    85.                 }
    86.  
    87.                 rollInputTimer = 0;
    88.             }
    89.         }
    90.  
    91.         private void HandleAttackInput(float delta)
    92.         {
    93.             inputActions.PlayerActions.RB.performed += i => rb_Input = true;
    94.             inputActions.PlayerActions.RT.performed += i => rt_Input = true;
    95.  
    96.             if(rb_Input)
    97.             {
    98.                 playerAttacker.HandleLightAttack(playerInventory.rightWeapon);
    99.             }
    100.  
    101.             if(rt_Input)
    102.             {
    103.                 playerAttacker.HandleHeavyAttack(playerInventory.rightWeapon);
    104.             }
    105.         }
    106.     }
    107. }
    108.  
     
  2. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    854
    Well what actions have you defined?
     
    Kurt-Dekker and PraetorBlue like this.