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

Script error

Discussion in '2D' started by AjesuisDessu, Nov 11, 2022.

Thread Status:
Not open for further replies.
  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 :
     

    Attached Files:

  2. jbnlwilliams1

    jbnlwilliams1

    Joined:
    May 21, 2019
    Posts:
    267
    Ok, you have now posted this 2 times and appear to have ignored requests from people to post better information.

    1. We need you to post the entire error message, not just the error code number. The entire message will tell us exactly what the erro is, and what line it is on.
    2. Most importantly, post your code using code tags so that it posts with the lines numbers. Screen shots, attachments or plain text posts of code will get you no where.
    3. We want to help you, but you must meet us at least 1/2 way with the information.
     
  3. AjesuisDessu

    AjesuisDessu

    Joined:
    Nov 8, 2022
    Posts:
    4
    but you can look at my script ? this is more simple no ?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,946
    No, because apparently you are not reading simple things we have asked you.

    For example:

    When you answer that and act like an adult forum member, I'm sure somebody will immediately help you!
     
  5. NeilB133

    NeilB133

    Joined:
    May 30, 2022
    Posts:
    169
    Like the guys have said, you're not being specific with what issue you're having. Despite this, just looking at the script it's clear to see that some of the syntax isn't correct, an IDE should point this out to you.

    So in the Jump function you have:

    Code (CSharp):
    1.     {
    2.         IsGrounded = Physics2D.OverlapCircle(checkGround.position, 0.5f, whatIsGround);
    3.  
    4.         if (IsGrounded)
    5.         {
    6.  
    7.  
    8.             {
    9.                 if (Input.GetKeyDown(KeyCode.Space)
    10.                 rb.velocity = new Vector2(rb.velocity.x, jumpForce);
    11.             }
    12.         }
    13.     }
    This should be:
    Code (CSharp):
    1.   IsGrounded = Physics2D.OverlapCircle(checkGround.position, 0.5f, whatIsGround);
    2.  
    3.         if (IsGrounded) {
    4.             if (Input.GetKeyDown(KeyCode.Space)) {
    5.                 rb.velocity = new Vector2(rb.velocity.x, jumpForce);
    6.             }
    7.         }
     
  6. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,002
    Please read the rules. This is not the right forum, you have put no effort into your post. The site is not a place for other people to do your work for you. Post the script properly, in the right place, explain what is happening and what is not happening. Provide information as to what you have already tried and what the results were.
    Closing. Please read the rules before starting a new thread.
     
    Kurt-Dekker likes this.
Thread Status:
Not open for further replies.