B
B
Bogodar2021-08-24 18:56:46
2D
Bogodar, 2021-08-24 18:56:46

Unity 2d c# code Showing error CS1041?

In my code it gives an error: Assets\Scripts\PlayerController.cs(5,13): error CS1041: Identifier expected; 'using' is a keyword.

Here is the actual code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Transform;
using static
using System;

namespace Assets.Scripts
{
    public class PlayerController : MonoBehaviour
    {
    //Направление
    [SerializeField] private bool facingRight = true;
    
    //Прыжки
    [SerializeField] private bool isGrounded;
    [SerializeField] public Transform feetPos;
    [SerializeField] public Transform groundCheck;
    [SerializeField] public LayerMask whatIsGrounded;
    [SerializeField] private int extraJumps;
    [SerializeField] public int extraJumpsValue;
    
    //Движение
    [SerializeField] private float moveInput;
        [SerializeField] private float speed;
        [SerializeField] private float jumpForce;
    [SerializeField] private Rigidbody2D rigidbody;
    
        private void Start()
        {
      extraJumpsValue;
            rigidbody = GetComponent<Rigidbody2D>();
        }
    //Движение код
        private void FixedUpdate()
        {
      isGrounded = Physics2D.OverlapCircle(feetPos.position, groundCheck, whatIsGrounded);
      
            moveInput = Input.GetAxis("Horizontal");
            rigidbody.velocity = new Vector2(moveInput * speed, rigidbody.velocity.y);
      if(facingRight == false && moveInput > 0)
      {
        Flip();
      }
      else if(facingRight == true && moveInput < 0)
      {
        Flip();
      }
    }
    //Прыжки код
    void update()
    {
      if(isGrounded == true)
      {
        extraJumps = extraJumpsValue;
      }
      
      if(Input.GetKeyDown(KeyCode.Space) && extraJumps > 0)
      {
        rigidbody.velocity = Vector2.up * jumpForce;
        extraJumps--;
      }
      else if(Input.GetKeyDown(KeyCode.Space) && extraJumps == 0 && isGrounded == true)
      {
        rigidbody.velocity = Vector2.up * jumpForce;
      }
    }
    //Направление код
    void Flip()
    {
      facingRight = !facingRight;
      Vector3 Scaler = transform.localScale;
      Scaler.x *= -1;
      transform.localScale = Scaler;
    }
  }
}

If I remove any using, it gives even more errors.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
ninrez, 2021-08-24
@ninrez

Remove using static. The error should disappear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question