- Home /
Grabbing an Inherited Variable
So I'm working on a RTS. I have a base WorldObject Script that has an enum called ObjectTypes with two values: Units & Buildings. I also have a Class for each of those that inherit from WorldObject. I want it so that when the player clicks a unit or building to select it, the script handling selection will first check to see if it is a unit or building based on the enum. But if I use something like GetComponent it's going to ask for the component that the enum is in. If I do GetComponent().objectType, it will return null because the component isn't WorldObject, it's either Unit or Building. Is there a way to do this or should I just create a bunch of tags and compare to those?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
An OS design issue: File types associated with their appropriate programs 1 Answer
Scriptable Object containing Scriptable Object 1 Answer
Is it bad to use "this" keyword for variables, methods etc. from base class? 2 Answers
Is it possible to make sealed overridden MonoBehaviour method. 0 Answers