playMaker

Author Topic: Tilemap related actions in prefabs: silencing the error check  (Read 1899 times)

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 816
Tilemap related actions in prefabs: silencing the error check
« on: November 16, 2024, 11:00:47 AM »
This issue concerns a Tilemap related action. In this case, "Tile World To Cell".

At the top of the Tile World To Cell action there are two fields. One is Tilemap Object and requires a GO. The next one is Tilemap and requires a component of type Tilemap. I tried the two gotten vars in their respective fields.

The action keeps throwing an error until a field is properly filled with either a GO that hosts a Tilemap component, or with a direct reference to said component.
That's fine when working directly in the scene but not so much when working in the prefab environment.

To have the action in the prefab shut up I tried relying on Global variables, at least temporarily.
Nothing works for the second field that looks for a Tilemap component reference since it's impossible to select a component from the Assets, not even a GO prefab that would be host to such a component. But for the first field it's possible to fool the action by using a Global var that stores a reference to a GO that hosts a Tilemap component. However this GO would need to be a prefab. You shove that Global var into the "Tilemap Object" field and the action zips it. Good.

But that would be useless until the Global var does contain a reference to a tilemap that is unique to each level. So we need an extra step such as when loading a level, we would pick the Tilemap GO of the current level (Grid > Tilemap) and save it into the Global var through some FSM, so then other instances of any other prefab that use a Tilemap action could see the Tilemap.

That's... very acrobatic.

The other solution is to rely on a 'Global_database' GO that contains plenty of useful variables, including all sorts of references to other GOs in the scene, and have each prefab use a "Find GO" action to detect said GO and then collect its variables.

But that is not possible because of the errors. So I excised the ErrorCheck() method in the action.

I think it would be better if the Tilemap actions could trust the user and only do some check at runtime when running in an instance of the prefab.

benjaminn

  • Playmaker Newbie
  • *
  • Posts: 1
    • slither io
Re: Tilemap related actions in prefabs: silencing the error check
« Reply #1 on: December 11, 2024, 08:36:00 PM »
Be mindful of the performance implications of using "Find GO" or other dynamic object lookups frequently.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15612
  • Official Playmaker Support
Re: Tilemap related actions in prefabs: silencing the error check
« Reply #2 on: December 13, 2024, 02:06:02 AM »
Hi,

 yes, prefer finding objects by tag, or even store them gameobjects during editing in fsm variables.

if the gameobjects are instances spawned at runtime, then tags will be best.

Bye,

Jean

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 816
Re: Tilemap related actions in prefabs: silencing the error check
« Reply #3 on: December 17, 2024, 12:17:39 PM »
I can create a tag only for the tilemap, so then when parsing the array where the result of 'Find GO by tag' is stored, it would be a quick operation to get the object because there shall only be one.