Search Unity

cs0103

Discussion in 'Getting Started' started by Andyloris, Jun 28, 2020.

  1. Andyloris

    Andyloris

    Joined:
    Jun 28, 2020
    Posts:
    2
    Hi,
    I'm developing a script to generate a random platform level,
    but the error cs0103
    is displayed and I have no idea
    where is he from,
    here is the source code of my script

    randomLevelsGeneration.cs

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Collections.Specialized;
    4. using UnityEngine;
    5. public class randomLevelsGenerator : MonoBehaviour
    6. {
    7.     public int isPlaced = 0;
    8.     public int forPlaced = 1;
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         while (forPlaced <= 32)
    13.         {
    14.             GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
    15.             cube.transform.position = new Vector3(Random.Range(-24.0f, 24.0f), 0, Random.Range(-24.0f, 24.0f));
    16.             if (isPlaced == 0)
    17.             {
    18.                 Player.transform.position = cube.transform.position;
    19.                 isPlaced = 1;
    20.             }
    21.             cube.transform.localScale = new Vector3(Random.Range(3.0f, 10.0f), 1, Random.Range(3.0f, 10.0f));
    22.             forPlaced++;
    23.         }
    24.     }
    25. }
    And thank you in advance!
     
    Last edited: Jun 28, 2020
  2. Andyloris

    Andyloris

    Joined:
    Jun 28, 2020
    Posts:
    2
    why no one
    wants to answer my question
     
  3. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    When posting error messages, please include the actual message as well; nobody memorizes the error codes.
    I'm guessing this line is the culprit:
    Code (CSharp):
    1. Player.transform.position = cube.transform.position;
    Unless you have a script called "Player" with a static Transform reference, "Player" doesn't exist.

    This is a forum, not a group chat. You're not likely to get answers right away.
     
    Joe-Censored and JoeStrout like this.