Categories
Mastering Development

Attempting to Instantiate an object using C# and Unity

So I am new to coding and I am using a book called “Learning C# by Developing Games in Unity 2019 – Fourth Edition. In one of the exercises it asks to instantiate an object who’s class is declared on a different .cs file, when I attempt to instantiate however it doesn’t work. I thought it would be because of a using statement but its not that either. Here is my code.

//LearningCurve.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LearningCurve : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Character hero = new Character();
    }

    // Update is called once per frame
    void Update()
    {

    }
}

//Character.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Character 
{

}

Leave a Reply

Your email address will not be published. Required fields are marked *