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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Error

Discussion in 'Scripting' started by AjesuisDessu, Nov 10, 2022.

  1. AjesuisDessu

    AjesuisDessu

    Joined:
    Nov 8, 2022
    Posts:
    4
    Hello, for some time on visual studio I have an error that I can not remove, I have searched the internet in vain I can not find any solution so now I ask on this forum. Here is my script :



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

    [DebuggerDisplay("{" + nameof(DebuggerDisplay) + "(),nq}")]
    public class PlayerController : MonoBehaviour
    {
    [SerializeField] float moveSpeed;
    [SerializeField] float jumpForce;

    Rigidbody2D rb;

    public Animator animator;

    public bool IsGrounded;
    [SerializeField] Transform checkGround;
    [SerializeField] LayerMask whatIsGround;

    // Start is called before the first frame update

    void Start()
    {
    rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
    Jump();
    }

    private void FixedUpdate()
    {
    Move();


    float characterVelocity = Mathf.Abs(rb.velocity.x);
    animator.SetFloat("Speed", characterVelocity);


    }

    private void Flip(float x)
    {
    throw new NotImplementedException();
    }

    void Move()
    {
    Vector2 movement = new Vector2(Input.GetAxis("Horizontal") * moveSpeed * Time.fixedDeltaTime, rb.velocity.y);
    rb.velocity = movement;



    }

    public override bool Equals(object obj)
    {
    return obj is PlayerController controller &&
    base.Equals(obj) &&
    DebuggerDisplay == controller.DebuggerDisplay;
    }

    private string DebuggerDisplay => ToString();

    void Jump()
    {
    IsGrounded = Physics2D.OverlapCircle(checkGround.position, 0.5f, whatIsGround);

    if (IsGrounded)
    {


    {
    if (Input.GetKeyDown(KeyCode.Space)
    rb.velocity = new Vector2(rb.velocity.x, jumpForce);
    }
    }
    }


    And this is my error :


    error CS1026 + error CS1513
     
  2. BABIA_GameStudio

    BABIA_GameStudio

    Joined:
    Mar 31, 2020
    Posts:
    491
    Provide us the full error messages and not just the codes. The codes are the least important parts of the errors. The full errors messages show us the line numbers and details of the errors.

    Also, post your code in code tags so we don't have to go through the whole script trying to match up the line numbers.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,946
    Go fix it! It's easy, here's how:

    Remember: NOBODY here memorizes error codes. That's not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

    The complete error message contains everything you need to know to fix the error yourself.

    The important parts of the error message are:

    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)
    - also possibly useful is the stack trace (all the lines of text in the lower console window)

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.
     
  4. AjesuisDessu

    AjesuisDessu

    Joined:
    Nov 8, 2022
    Posts:
    4
    Provide us the full error messages and not just the codes. The codes are the least important parts of the errors. The full errors messages show us the line numbers and details of the errors.

    Also, post your code in code tags so we don't have to go through the whole script trying to match up the line numbers.



    Okay so here is my script
     

    Attached Files:

  5. flasker

    flasker

    Joined:
    Aug 5, 2022
    Posts:
    193
    no one is gonna download your script and open it in unity, its too much hassle