playMaker

Author Topic: Find game object - clutter  (Read 2011 times)

troubleMaker

  • Playmaker Newbie
  • *
  • Posts: 25
Find game object - clutter
« on: April 09, 2014, 08:40:49 AM »
Hi,

I'm an artist making my first game prototype, and i notice that i need to reference the player character a LOT. Enemies need find the player, used skills need to find player for stats, everything and everybody needs to find the player. I can use the Find game object - action and store it in a variable for sure, but i'm just copy pasting this to so many places it seems to me quite inefficient and cluttering.

I wanted a FSM to find the player character and other important objects at game load and store them to Global variables and this works very nicely for me, but all the prefabs moan about it not being allowed to use scene objects, but only other prefabs as referenced objects. It still works, but my error log is really big now  :)

Should i be doing something else?
« Last Edit: April 09, 2014, 03:45:15 PM by troubleMaker »

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: Find game object - clutter
« Reply #1 on: April 09, 2014, 07:43:07 PM »
This happens to me all the time.

Sometimes I just decide to not use a prefab. Depending on how often I need to re-use that object, it might not be worth it to prefab it and just duplicate it instead.

Other times, I'll make prefabs of whatever the original prefab is targeting as well. In this case, I'd prefab your character (even though there will only ever be one) and link to the prefab character within your prefabs. Once you bring them into the scene, they'll know to target the character in the scene as well.

troubleMaker

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Find game object - clutter
« Reply #2 on: April 13, 2014, 02:07:07 PM »
OK,

Thanks a lot for the reply. But what do you mean by duplicating in this case? I also tried referencing the player prefab in the project folder, like you said, but then the scene objects really reference the folder object and never seem to become aware that there is an instanced version in the scene with them. So how do i make them become aware like in your example?

Thanks! :)

TIGGYsmalls

  • Junior Playmaker
  • **
  • Posts: 80
Re: Find game object - clutter
« Reply #3 on: April 13, 2014, 04:02:50 PM »
I'm not sure if this is what you want but I just

Get Owner (Call it something like Self)

then

Set Game Object (Then I set a Global Object as Self)

You get the error about Referencing Prefabs but it still seems to work.