playMaker

Author Topic: Referencing Scene Object Mindset  (Read 926 times)

rechronicle

  • Full Member
  • ***
  • Posts: 119
  • Mystvaldia
    • Indie RPG Creator
Referencing Scene Object Mindset
« on: June 14, 2019, 11:23:31 AM »
Hello,
recently I found out that I can reference GO from parent/sibling/child or even 'Get Property' and keep the reference connected even if I put it into Prefabs. Is it a good practice in the long run?

Previously, I'm using less scene referencing because it's kind of loose and easily break (iirc read it somewhere) if something happens to the object. Maybe it wasn't true for the static object that always on the screen?

So, I come to a conclusion:
- Referencing from the scene is okay if the object is static/always in the scene. Even better if it's part of the parent/sibling/child object.
- Use 'find with...' for instantiated/replaceable GO, like spawned enemies/character variation.


What's your thought about this workflow?
Thank you!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Referencing Scene Object Mindset
« Reply #1 on: June 15, 2019, 05:48:38 AM »
Hi.
If prefabs are preset in a Scene its ok to reference directly to other fsms/GO
But if prefab would be created @runtime, then its a no no.
You can use a global tho, but you should minimize using globals.

Usually i have a object with some fsms (Data / array / reference to other object / etc.

@start i will place this object into the global so i can easily access from other objects.
Then on that data fsm i will have all the data that i need (score / lives / reference to other objects / etc.

for reference to other objects i would only need to use 'find gameobject' once!
 Then if another fsm/object would need this i can use "Get Fsm Gameobject" and get it from the data (Meta) object

This way i only need 1 Global and would only need to 'Find' objects once.

There are many 'Fsm' actions available, and even more on the Ecosysytem