Trouble with creating objects
Hi, I'm a month old to Unity, but not new to programming. I created a class in my GameManager script and am trying to create an object of that class in my PlayerController script. This is as far as I have gotten:
public class PlayerController : MonoBehavior {
private GameManager.Boundaries boundariesClass;
void Start() {
boundariesClass = GameObject.Find("Game Manager").GetComponent<GameManager.Boundaries>();
}
}
I have been able to use functions from getting the GameManager script this way, and I can even access methods inside of the Boundaries class using boundariesClass.customMethod, however I have been struggling how to simply create a class of type Boundaries:
Boundaries myBoundaries = new Boundaries();
I swear I have done my research and have come up empty handed (everything I find is about creating objects from a class that is in the same script the object is being created in). Thanks in advance.
Answer by harperrhett · May 01, 2020 at 08:52 PM
Figured it out, I just have to create a new script that doesn't derive from monobehavior.
Your answer
Follow this Question
Related Questions
I can not use classes 1 Answer
Managing In-Game Variables of Different Data Types 1 Answer
How do I modify variables from a different class that belongs to the same C# file? 1 Answer
How can I add functions via a scriptswizzard variable? 0 Answers
The script don't inherit a native class that can manage a script. 0 Answers