Search Unity

Can't execute my first script

Discussion in 'Getting Started' started by bichorobles, Sep 27, 2019.

  1. bichorobles

    bichorobles

    Joined:
    Sep 27, 2019
    Posts:
    1
    I want to run the script in the scene to see if it is doing it ok in console, but when I press play it says "All compiler errors have to be fixed before you can enter playmode"

    It because the code or what?, IDK what to do

    here's the code:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class comportamiento : MonoBehaviour {

    public string playerName = "Luis Robles";
    public int playerScore = 0;
    private int maxScore = 120;
    public int playerAge = 0;

    // Start is called before the first frame update
    void Start(){

    Debug.Log(playerScore + 12);


    }

    // Update is called once per frame
    void Update(){
    if (Input.GetKeyUp(GetKeyCode)) BirthDay();
    }


    void BirthDay() {

    Debug.Log(playerAge + 1);
    }

    }
     
    Last edited: Sep 27, 2019
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Yes something is wrong with your script/s.
    You should see some error messages in the Console. Post the errors here.
    It looks like its something to do with:
    Code (csharp):
    1. if (Input.GetKeyUp(GetKeyCode)) BirthDay();
    GetKeyCode has not been declared.
    Do you want a specific key?

    Take a look at our learn section, we have plenty of materials to help get you started https://unity.com/learn
     
    Ryiah likes this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Your code editor should have brought attention to these code errors as soon as you typed them. If you didn't notice the usually red squiggly lines in your code editor then the console will include the exact line numbers where it believes the problem is in your code (basically the point where the compile fails, which is either on the exact line or a line or two later but still really close).
     
    karl_jones and Ryiah like this.