Search Unity

error CS1513: } expected

Discussion in 'General Discussion' started by actab001, May 13, 2020.

  1. actab001

    actab001

    Joined:
    May 12, 2020
    Posts:
    3
    Does anyone have a solution to this problem?
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi,

    Please use code tags in your future posts (instead of attachments.)

    Code (CSharp):
    1. velocity.y = Mathf,Sqrt(jumpHeight * -2f * gravity);
    Should be:

    Code (CSharp):
    1. velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
    You need to be accurate with coding. You should have seen some error notification in your IDE when you tried that code, too. Red squiggly line there...?
     
  3. actab001

    actab001

    Joined:
    May 12, 2020
    Posts:
    3
    this is what it says.
     

    Attached Files:

  4. actab001

    actab001

    Joined:
    May 12, 2020
    Posts:
    3
    Thank you it is now working
     
  5. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Did you read what I actually wrote? Just fix the typo and your code will compile. That comma you have written there erroneously causes the compiler error.
     
  6. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @Ryiah the code was earlier included as an attachment... But looks like it's been now removed from the OP. And there was one single typo, which I pointed out, and it fixed the compiler errors.
     
  7. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,205
    Yeah I removed my post after I typed it up because I realized it had to have existed at some point.
     
  8. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @actab001 It's not really useful / good to remove already posted code/information. There's not much benefit to others later if the original problem is missing. And this is not a "have your work done for free" forum.