Search Unity

Question the name does not exist ??

Discussion in 'Editor & General Support' started by silversaintsco, Jun 9, 2020.

  1. silversaintsco

    silversaintsco

    Joined:
    Jun 9, 2020
    Posts:
    3
    1) error CS0103: The name 'gameobject' does not exist in the current context
    2) error CS0103: The name 'instantiate' does not exist in the current context

    i dont get what im doing wrong ??


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PipeUp : MonoBehaviour
    6. {
    7.  
    8.     private Character character;
    9.     public GameObject pipeDown;
    10.     // Use this for initialization
    11.     void Start()
    12.     {
    13.         character = FindObjectOfType<Character>();
    14.     }
    15.  
    16.  
    17.     // Update is called once per frame
    18.     void Update()
    19.     {
    20.         if (character.transform.position.x - transform.position.x > 30)
    21.         {
    22.  
    23.             float xRan = Random.Range(0, 10);
    24.             float yRan = Random.Range(-5, 5);
    25.             float gapRan = Random.Range(0, 3);
    26.  
    27.             instantiate(gameobject, new Vector2(character.transform.position.x + 30 + xRan, -11 + yRan), transform.rotation);
    28.             instantiate(pipeDown, new Vector2(character.transform.position.x + 30 + xRan, 12 + gapRan + yRan), transform.rotation);
    29.             Destroy(gameObject);
    30.  
    31.         }
    32.     }
    33.  
    34.     void OnCollisionEnter2D(Collision2D other)
    35.     {
    36.         if (other.gameObject.tag == "Player")
    37.         {
    38.             character.Death();
    39.         }
    40.     }
    41.  
    42. }
    43.  
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    Instantiate needs a capital I at the start and gameObject needs a capital O for object.