How do I fix error CS0103: The name '.' does not exist in the current context

How do I fix error CS0103: The name 'crouching'
How do I fix error CS0103: The name 'sprinting'
How do I fix error CS0103: The name 'crouchTimer'
How do I fix error CS0103: The name 'lerpCrouch'

I added the PlayerInput (Input Actions) but it doesn’t detect the input values I assigned

image

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

public class PlayerMotor : MonoBehaviour
{
    private CharacterController controller;
    private Vector3 playerVelocity;
    private bool isGrounded;
    public float speed = 5f;
    public float gravity = -9.8f;
    public float jumpHeight = 3f;
    // Start is called before the first frame update
     void Start()
    {
        controller = GetComponent<CharacterController>();
    }
    // Update is called once per frame
    void Update()
    {
        isGrounded = controller.isGrounded;
        if (lerpCrouch)
        {
            crouchTimer += Time.deltaTime;
            float p = crouchTimer / 1;
            p *= p;
            if (crouching)
                controller.height = Mathf.Lerp(controller.height, 1, p);
            else
                controller.height = Mathf.Lerp(controller.height, 2, p);
            
            if (p >1)
            {
                lerpCrouch = false;
                crouchTimer = 0f;
            }
        }
    }
      public void Crouch()
      {
          crouching = !crouching;
          crouchTimer = 0;
          lerpCrouch = true;
      }
      
      public void Sprint()
      {
          sprinting = !sprinting;
          if (sprinting)
              speed = 8;
          else
              speed = 5;
      }
    public void ProcessMove(Vector2 input)
    {
        Vector3 moveDirection = Vector3.zero;
        moveDirection.x = input.x;
        moveDirection.z = input.y;
        controller.Move(transform.TransformDirection(moveDirection) * speed * Time.deltaTime);
        playerVelocity.y += gravity * Time.deltaTime;
        if (isGrounded && playerVelocity.y < 0)
             playerVelocity.y = -2f;
        controller.Move(playerVelocity * Time.deltaTime);
        Debug.Log(playerVelocity.y);
    }
    public void Jump()
    {
        if (isGrounded)
        {
            playerVelocity.y = Mathf.Sqrt(jumpHeight * -3.0f * gravity);
        }
    }
}

1 Answer

1

You didnt’t create these variables…