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. Dismiss Notice

Error CS1003: Syntax error, ',' expected

Discussion in 'Scripting' started by JDinoman, Jan 26, 2021.

  1. JDinoman

    JDinoman

    Joined:
    Jan 26, 2021
    Posts:
    26
    I've learned quite a lot about unity myself, (literally all by myself) but I guess it's time for me to actually learn the right way. So I decided to download and run a 1st Unity tutorial. I run Unity 2018.3 and I cannot obtain the newer versions. (don't ask.) It said: "Required: Unity 2018.3 or above." well, I got unity 2018.3, so nothing should go wrong. Well, I was totally wrong. I had 11 compiler errors. I used my self-taught Unity knowledge to fix 10 of 11 compiler errors, but this last one I can't fix. Can someone help?

    Here is the Compiler error:
    Assets\Content\game\Scripts\PlayerAvatar.cs(9,57): error CS1003: Syntax error, ',' expected

    Here's the script:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityStandardAssets.Characters.ThirdPerson;
    using UnityEngine.Events;
    using Unity.Tutorials;

    [RequireComponent(typeof(Animator))]
    public class PlayerAvatar : MonoBehaviour, IPlayerAvatar; ;
    {
    public UnityEvent OnDeath;
    public UnityEvent OnRespawn;
    public float respawnDelay = 5;

    GameController gameController;
    Animator animator;
    WaitForSeconds delay;
    new CapsuleCollider collider;

    void Awake()
    {
    animator = GetComponent<Animator>();
    collider = GetComponent<CapsuleCollider>();
    delay = new WaitForSeconds(respawnDelay);
    gameController = FindObjectOfType<GameController>();
    }

    public void Die()
    {
    StartCoroutine(DieThenRespawn());
    }

    IEnumerator DieThenRespawn()
    {
    animator.SetBool("DeathTrigger", true);
    var controller = GetComponent<ThirdPersonUserControl>();
    if (controller != null)
    controller.enabled = false;
    collider.height = 0.2f;
    collider.center = new Vector3(0, 0.3f, 0);
    OnDeath.Invoke();
    yield return delay;
    OnRespawn.Invoke();
    animator.SetBool("DeathTrigger", false);
    animator.Rebind();
    if (controller != null)
    controller.enabled = true;
    collider.height = 1.6f;
    collider.center = new Vector3(0, 0.8f, 0);

    gameController.RestartLevel();
    }
    }


    And yes, I am aware that in line 9, there's two ";" marks. There used to be a "Type Expected" error, and that's how I fixed it. It doesn't look right, so I'm guessing that's not how I should've fixed it. I'm not a scripter, not even close.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
  3. JDinoman

    JDinoman

    Joined:
    Jan 26, 2021
    Posts:
    26
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    Did you read Antistone's guide above? The error above is telling you the exact character and line number where the error is!

    What do you see on line 9 and character position 57? The error above is guiding you to EXACTLY the character that is wrong. I don't think it can do anything more than that.

    REMOVE the two semicolons. Punctuation is not arbitrary.. this isn't Javascript, you can't just sprinkle semicolons everywhere and hope for the best. Everything has to be spelled, capitalized and punctuated PRECISELY the way it is intended otherwise the program doesn't work.
     
    JDinoman likes this.
  5. JDinoman

    JDinoman

    Joined:
    Jan 26, 2021
    Posts:
    26
    Thank you. Also, I don't do JavaScript.
     
  6. JDinoman

    JDinoman

    Joined:
    Jan 26, 2021
    Posts:
    26
    Wait, hold on... Did you give me the right link? what is see is something totally different. It's an Error CS1003, but it's much different.
     
  7. JDinoman

    JDinoman

    Joined:
    Jan 26, 2021
    Posts:
    26
    Ok I removed both the semicolons. Now what? I tried putting a comma after IPlayerAvatar on line 9, letter 57. That just pulled up a new error, "Type Expected." So if it's not a comma, semicolon, or just plainly nothing, then what is it?
     
  8. Boz0r

    Boz0r

    Joined:
    Feb 27, 2014
    Posts:
    419
    It should be nothing. What error are you getting then?
     
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
  10. JDinoman

    JDinoman

    Joined:
    Jan 26, 2021
    Posts:
    26
    well the error i'm getting now is that IPlayerAvatar is like some wrong reference or something
     
  11. JDinoman

    JDinoman

    Joined:
    Jan 26, 2021
    Posts:
    26
    yeah I didn't make the code. are you familiar with cameras in unity? because if you are, then do you know how to split a camera? I mean, I want 2 cameras but i can't find out how to split them into 2 different cameras.
     
  12. JDinoman

    JDinoman

    Joined:
    Jan 26, 2021
    Posts:
    26
    well I mean, i want two cameras, one on each side of the screen, not one camera into two, because that's obviously impossible.
     
  13. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    Do you mean maybe, unity split screen?

    Screen Shot 2021-01-26 at 12.39.45 PM.png
     
  14. JDinoman

    JDinoman

    Joined:
    Jan 26, 2021
    Posts:
    26
    yes, what else would I mean, on a unity forum?
     
  15. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    What else would I mean by showing you a screenshot of a google search for split screen tutorials that returned over 16 million hits?

    Go work through two or three split screen tutorials. This is super super super simple stuff and nobody here is going to type it all out for you again.
     
    JoNax97 likes this.
  16. JDinoman

    JDinoman

    Joined:
    Jan 26, 2021
    Posts:
    26
    Yeah I found out myself that it's the viewport rectangle thingy. And I'm no genius, I've never used Unity before.