playMaker

Author Topic: Refer to an object generated during runtime  (Read 46 times)

Justakin

  • Playmaker Newbie
  • *
  • Posts: 1
Refer to an object generated during runtime
« on: May 22, 2026, 04:08:10 AM »
I’m new to PlayMaker and Unity, so sorry if I’m not using the right terms.

I want to use objects that are created at runtime and reference them from other objects. Specifically, I want to click on a surface to spawn new objects, and then use those spawned points to draw a spline between them. However, it seems like I can only reference GameObjects that already exist in the scene. Am I missing something, or is what I’m trying to do not possible this way?

LeDisciple

  • Playmaker Newbie
  • *
  • Posts: 46
Re: Refer to an object generated during runtime
« Reply #1 on: Today at 05:42:40 PM »
Hi,

My game I working on is ALL generated at runtime (to get a random level every time) so yes it's very possible. What you have to do is to create pools with Array tables or hash tables depending of your needs. As a exemple: when I spawn a prefab on certain spot I put it's name (yes when they are created I change their name to be more specific like 1,2,3,4,etc. not with the "(clone)" suffixe created by unity) into an array and the Gomeobject into an array too. So if I search for something like "by name", with the index of the array I can refering directly with the same index into the GameObject array. You can even save child object into an array, all depends of what you need.

As I said, it's an example, I do not know how you would proceed but play a lot with the Array/hash tables. I use EasySave to save those array/hash and all the things created at runtime. When I open a saved game, I look if an EasySave files exists and my spaghetti code put everything where it belongs.

Have fun!  ;)