Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Jump script problems Assets\SCRIPS\Saltar.cs(40,61): error CS1003: Syntax error, ',' expected

Discussion in 'Scripting' started by loconajsdbjsgvbdyhasbk, Jul 13, 2021.

  1. loconajsdbjsgvbdyhasbk

    loconajsdbjsgvbdyhasbk

    Joined:
    Jul 13, 2021
    Posts:
    6
    Hello colleagues I have problems in my script I want to play my game but it throws me this error
    Assets\SCRIPS\Saltar.cs(40,61): error CS1003: Syntax error, ',' expected

    public class Saltar : MonoBehaviour
    {
    public float velocidadMovimiento = 5.0f;
    public float velocidadRotacion = 200.0f;
    private Animator anim;
    public float x, y;
    public Rigidbody rb;
    public float fuerzaDeSalto = 8f;
    public bool puedoSaltar;
    // Use this for initialization
    void Start()
    {
    puedoSaltar = false;
    anim = GetComponent<Animator>();
    }
    void FixedUpdate()
    {
    transform.Rotate(0, x * Time.deltaTime * velocidadRotacion, 0);
    transform.Translate(0, 0, y * Time.deltaTime * velocidadMovimiento);
    }
    // Update is called once per frame
    void Update()
    {
    x = Input.GetAxis("Horizontal");
    y = Input.GetAxis("Vertical");
    anim.SetFloat("VelX", x);
    anim.SetFloat("VelY", y);
    if (puedoSaltar)
    {
    if (Input.GetKeyDown(KeyCode.Space))
    {
    anim.SetBool("salte", true);
    rb.AddForce(new Vector3(0, fuerzaDeSalto, 0)ForceMode.Impulse);
    }
    anim.setBool("tocoSuelo", true);
    }
    else
    {
    EstoyCayendo();
    }
    }
    public void EstoyCayendo()
    {
    anim.setBool("tocoSuelo", false);
    anim.SetBool("salte", false);
    }
    }

    It's in Spanish, I'm Spanish

    I would like to develop my game but this throws me I do not know much programming could you help me
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    Absolutely! Start with these guys, they're GREAT:

    Imphenzia / imphenzia - super-basic Unity tutorial:



    Jason Weimann:



    Brackeys super-basic Unity Tutorial series:



    Sebastian Lague Intro to Game Development with Unity and C#:



    Imphenzia: How Did I Learn To Make Games:



    How to do tutorials properly:

    Tutorials are a GREAT idea. Tutorials should be used this way:

    Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That's how software engineering works. Every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly. Fortunately this is the easiest part to get right. Be a robot. Don't make any mistakes. BE PERFECT IN EVERYTHING YOU DO HERE.

    Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

    Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost.

    Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there's an error, you will NEVER be the first guy to find it.

    Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!

    For the specific error above, if you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/

    Remember: NOBODY memorizes error codes. 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.

    Always start with the FIRST error in the list, as sometimes that error causes or compounds some or all of the subsequent errors.

    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)

    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.

    How to understand compiler and other errors and even fix them yourself:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    Finally, if you really get stuck, how to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220
     
    Yoreki likes this.
  3. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    As the error is telling you, you are missing a comma somewhere. If you used code tags, i could give you a better answer. Roughly estimating where line 40 is, you are at least missing one in rb.AddForce (separating the vector and forcemode), but there may be other problems with your code as well. Please use code tags in the future.
     
  4. loconajsdbjsgvbdyhasbk

    loconajsdbjsgvbdyhasbk

    Joined:
    Jul 13, 2021
    Posts:
    6
    Gracias por su repuesta rapida tendre en cuenta lo que me dijeron Arigatooo!!!
     
    Kurt-Dekker likes this.
  5. loconajsdbjsgvbdyhasbk

    loconajsdbjsgvbdyhasbk

    Joined:
    Jul 13, 2021
    Posts:
    6
    [código = CSharp] usando System.Collections;
    utilizando System.Collections.Generic;
    usando UnityEngine;

    Saltar de clase pública: MonoBehaviour
    {
    flotador público velocidadMovimiento = 5.0f;
    flotador público velocidadRotacion = 200.0f;
    animador privado;
    flotador público x, y;


    public Rigidbody rb;
    flotador público fuerzaDeSalto = 8f;
    public bool puedoSaltar;

    // Use esto para la inicialización
    inicio vacío ()
    {
    puedoSaltar = falso;
    anim = GetComponent <Animator> ();
    }

    anular FixedUpdate ()
    {
    transform.Rotate (0, x * Time.deltaTime * velocidadRotacion, 0);
    transform.Translate (0, 0, y * Time.deltaTime * velocidadMovimiento);
    }

    // La actualización se llama una vez por fotograma
    Void Update ()
    {
    x = Input.GetAxis ("Horizontal");
    y = Input.GetAxis ("Vertical");

    anim.SetFloat ("VelX", x);
    anim.SetFloat ("VelY", y);

    si (puedoSaltar)
    {
    si (Input.GetKeyDown (KeyCode.Space))
    {
    anim.SetBool ("salte", verdadero);
    rb.AddForce (nuevo Vector3 (0, fuerzaDeSalto, 0), ForceMode.Impulse);
    }
    anim.SetBool ("tocoSuelo", verdadero);
    }
    demás
    {
    EstoyCayendo ();
    }
    }

    público vacío EstoyCayendo ()
    {
    anim.SetBool ("tocoSuelo", falso);
    anim.SetBool ("salte", falso);
    }
    }[/código]
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
  7. loconajsdbjsgvbdyhasbk

    loconajsdbjsgvbdyhasbk

    Joined:
    Jul 13, 2021
    Posts:
    6
    I tried to use the code tag and it didn't work for me so it came out, could you tell me if it's okay and forgive me for the inconvenience
    upload_2021-7-13_16-57-32.png
     
  8. loconajsdbjsgvbdyhasbk

    loconajsdbjsgvbdyhasbk

    Joined:
    Jul 13, 2021
    Posts:
    6
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class Saltar : MonoBehaviour
    7. {
    8.     public float velocidadMovimiento = 5.0f;
    9.     public float velocidadRotacion = 200.0f;
    10.     private Animator anim;
    11.     public float x, y;
    12.  
    13.  
    14.     public Rigidbody rb;
    15.     public float fuerzaDeSalto = 8f;
    16.     public bool puedoSaltar;
    17.  
    18.     // Use this for initialization
    19.     void Start()
    20.     {
    21.         puedoSaltar = false;
    22.         anim = GetComponent<Animator>();
    23.     }
    24.  
    25.     void FixedUpdate()
    26.     {
    27.         transform.Rotate(0, x * Time.deltaTime * velocidadRotacion, 0);
    28.         transform.Translate(0, 0, y * Time.deltaTime * velocidadMovimiento);
    29.     }
    30.  
    31.     // Update is called once per frame
    32.     void Update()
    33.     {
    34.         x = Input.GetAxis("Horizontal");
    35.         y = Input.GetAxis("Vertical");
    36.  
    37.         anim.SetFloat("VelX", x);
    38.         anim.SetFloat("VelY", y);
    39.  
    40.         if (puedoSaltar)
    41.         {
    42.             if (Input.GetKeyDown(KeyCode.Space))
    43.             {
    44.                 anim.SetBool("salte", true);
    45.                 rb.AddForce(new Vector3(0, fuerzaDeSalto, 0), ForceMode.Impulse);
    46.             }
    47.             anim.SetBool("tocoSuelo", true);
    48.         }
    49.         else
    50.         {
    51.             EstoyCayendo();
    52.         }
    53.     }
    54.  
    55.     public void EstoyCayendo()
    56.     {
    57.         anim.SetBool("tocoSuelo", false);
    58.         anim.SetBool("salte", false);
    59.     }
    60. }
     
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    You need to stop writing in your native language.

    The correct keyword is
    if
    , not
    si
     
  10. loconajsdbjsgvbdyhasbk

    loconajsdbjsgvbdyhasbk

    Joined:
    Jul 13, 2021
    Posts:
    6
    Now can you just toast me if it's okay? sorry for everything