playMaker

Author Topic: How to locate an object based on a variable set in Playmaker actions?  (Read 2394 times)

ToxicFrog

  • Beta Group
  • Full Member
  • *
  • Posts: 139
Hello, Playmaker gurus.

I began using this tool a few weeks ago, and absolutely love it. I've been working on a prototype, and so far I have managed to make it work as intended. However, I've run into a rut and I can't seem to figure out how to solve a presumably simple problem.

If someone would be willing to walk me through the process to accomplish what I need, I will greatly appreciate it and reply with results!

Here's what I need to to:
There is a global int called 'Total_Sequence'. It starts at 1, and is increased by 1 with each tile touched.

As I interact with tiles on a grid, I give them the following variables:

SEQ_ID (int). This is the tile's order in a sequence. Each tile touched has a SEQ_ID of 'Total_Sequence + 1'.


Here is my question:
How can I use Playmaker to locate an object with a specific SEQ_ID? In other words, if I've created 10 tiles and want to locate the tile with SEQ_ID of 8, how can that be done?

Once I locate that tile, I will perform more actions on it, but I have not been successful in finding a way to locate an object based on a variable contained inside the object.

I'm sure it's a fairly simple thing to do that I am simply overlooking. Id' appreciate any assistance.

Please advise - thanks!

ToxicFrog

  • Beta Group
  • Full Member
  • *
  • Posts: 139
Re: How to locate an object based on a variable set in Playmaker actions?
« Reply #1 on: February 24, 2015, 11:35:38 AM »
Perhaps I overcomplicated my question.

Let me rephrase:

I need to find a gameobject in the scene with a specific variable value, and then store that gameobject for further actions.

In this case, I want to find and object with the integer value of "SEQ_ID=8".

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: How to locate an object based on a variable set in Playmaker actions?
« Reply #2 on: February 24, 2015, 01:53:52 PM »
Hi,

 I think you should revert the problem.

first way to do this:

 send a global event "WHO IS SEQID" and pass in the event data the value 8, then any objects can implement in its fsm this global event, check the value passed with that event against his local value and if it matches, it can fire in turn a global event "I AM HERE", and the fsm that sent the initial "WHO IS SEQID" would wait for this event before procedure further, or if you want to stay synchronized, the matching fsm would save itself into a global variable "Current SEQID" or something.

 But this kind of problem you are facing really calls for a brainstorm and maybe refactor where you host your logic, maybe the fsm with this seqID value should be aware someone is looking for it.

OR, you can use ArrayMaker, and maintain a hashtable with the seqids as the key and the gameobject as a variable. that would be a very reliable and clean way, then anyone interested in accessing a particular seqid only needs to know about this arrayMaker GameObject, that is unique in your hierarchy.

 Bye,

 Jean


 Bye,

 Jean

ToxicFrog

  • Beta Group
  • Full Member
  • *
  • Posts: 139
Re: How to locate an object based on a variable set in Playmaker actions?
« Reply #3 on: February 24, 2015, 02:20:42 PM »
Thanks, Jean.

I've done some reading, and it does sound like Arraymaker could be the answer I'm looking for (for other problems as well).

My problem is that I've not found any tutorial resources for it, so I'm flying blind (even with the example projects).

Here's what I'd like to include in a hashtable using arraymaker:

SEQID1 (int)
SEQID2 (int)
ActiveStatus (bool)

If you can give me a simple description for how I'd use Arraymaker to generate this table, I bet I can figure it out from there. I just don't know where to start!

Much appreciated, and thanks for being such a reliable resource on these boards (I've found answers to many questions just by reading your replies)!


ToxicFrog

  • Beta Group
  • Full Member
  • *
  • Posts: 139
Re: How to locate an object based on a variable set in Playmaker actions?
« Reply #4 on: February 24, 2015, 03:00:39 PM »
Actually, want I really want to do (assuming I understand how Arraymaker works in theory):

Keep an array that starts off empty.
When a tile is activated, it is added to the array with these properties:

SEQID1 (int)
SEQID2 (int)
ActiveStatus (bool)


So it would look something like this:
Gameobject Tile 1, SEQID1 1, SEQID2 20, true
Gameobject Tile 2, SEQID1 2, SEQID2 21, true
Gameobject Tile 3, SEQID1 3, SEQID2 22, true
etc
etc

Then, once a global event 'DONE' is broadcast, I'd send an event 'LIGHTUP' to each object in the array, in order of their SEQID.


So Tile 1 would LIGHTUP, then Tile 2, then Tile 3, etc.

Does that make sense?