Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Krillan87 on March 06, 2017, 08:54:34 AM

Title: Best practice for finding un-instantiated objects?
Post by: Krillan87 on March 06, 2017, 08:54:34 AM
Hi,

I am just curious on how people usually assign/declare varibles that has not been instanitaed into the game yet.

In my game there is a lot of stuff (treasures, enemies, NPS etc) that have a "Find game object with tag: Player" on them. The thing is it's a multiplayer game with Photon so the when the game starts the player have not yet been instantiated (Because the user needs to create a room before the player instantiates).

So all the "stuff" in the scene obviously can't find a  player yet (because no player yet exists) and the variables don't get assigned.

There are plenty of different ways to solve this small issue but I was just courses on how people usually solve this. IS there a "best" way to solve this?

bye,
Christian
Title: Re: Best practice for finding un-instantiated objects?
Post by: jeanfabre on March 07, 2017, 12:57:23 AM
Hi,

The Player should broadcast a global event "ON PLAYER INITIALIZED" or something like that, then all interested fsm can catch this and store the sender of this event which will be the player.

 That's one way that works for me, but looking for gameobejct by tag is also good, but NEVER use FindGameObject using the name, it's not performing very well, and if you change the name it won't work anymore...
 
Bye,

 Jean
Title: Re: Best practice for finding un-instantiated objects?
Post by: Krillan87 on March 07, 2017, 10:33:19 AM
Hi,

The Player should broadcast a global event "ON PLAYER INITIALIZED" or something like that, then all interested fsm can catch this and store the sender of this event which will be the player.

 That's one way that works for me, but looking for gameobejct by tag is also good, but NEVER use FindGameObject using the name, it's not performing very well, and if you change the name it won't work anymore...
 
Bye,

 Jean

Alright good points! I'm still a bit new to Playmaker so I haven't got into how "broadcasting" works yet....but judging by the name it sounds pretty straightforward, so I think already got a good idea on how it works. Gonna look into that solution tomorrow. Thanks jean :)
Title: Re: Best practice for finding un-instantiated objects?
Post by: jeanfabre on March 09, 2017, 01:25:43 AM
Hi,

Good luck :) make sure you watch videos on this and check out all the samples on the Ecosystem (https://hutonggames.fogbugz.com/?W1181), also follow me on twitter (https://twitter.com/JeanAtPlayMaker) to get news and updates on the Ecosystem content and playmaker in general.

Bye,

 Jean
Title: Re: Best practice for finding un-instantiated objects?
Post by: djaydino on March 09, 2017, 03:00:22 AM
Hi,
You might want to check out the "Global events and Global Transitions" tutorial on the User Tutorial wiki page (https://hutonggames.fogbugz.com/default.asp?W548)
It is in the Beginner section.