Hi, if I want to create multiple instances of an object, but have it referred to in the code, how do I go about doing that? I’m asking cause I want to avoid creating too many of the same global object by name.
For reference, I’m creating spawn points, but rather than name them as Spawn1, Spawn2, Spawn 3, as global variables, I’d like to scrimp on this and have them as individual instances.
If you mean you’d like to be able to refer to each instance of the object individually then make an instance variable (for example, called id), ideally a number, and give each object a unique id as it’s spawned. If you use sequential numbers, then you’ll have to keep track of the latest number in a global variable.
Is there a way to label them in the visual editor?
If you create the objects in the editor, then yes. When you drag the object to the scene and click on it to get focus, then you’ll also get the object properties panel on the left. At the bottom of this are the modifiable object variables. Changing it here will only change it for that one object.
Awesome, it worked. Thanks so much.