playMaker

Author Topic: How to control a 10x10 array of objects?  (Read 4171 times)

mekoid

  • Playmaker Newbie
  • *
  • Posts: 36
How to control a 10x10 array of objects?
« on: December 13, 2014, 12:16:19 PM »
Hi Guys,
I am new to pM.
I have a flipping floor consisting of 10 x 10 boards.
1) Each of the boards might flip under certain conditions.
2) All of them have an occasion that needs them to flip randomly.
How do I achieve the above 1) and 2) efficiently ???
Any help or hint will be very much appreciated.
Thanks!
« Last Edit: December 23, 2014, 02:03:37 AM by mekoid »

mekoid

  • Playmaker Newbie
  • *
  • Posts: 36
Re: How to control a 10x10 array of objects?
« Reply #1 on: December 15, 2014, 09:36:45 AM »
guess no one has any ideas... :'(

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: How to control a 10x10 array of objects?
« Reply #2 on: December 15, 2014, 09:49:11 AM »
It seems like you just need a prefab for that floor tile with the behavior and conditions designed into it. You can send events from some other FSM, like a puzzle manager sort of thing... Is that what you're looking for?

The question is a bit open ended.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to control a 10x10 array of objects?
« Reply #3 on: December 16, 2014, 02:43:24 AM »
Hi,

 a 10*10 array is manageable using ArrayMaker and a hashtable.

 your hashtable key will be a string following a strict convention:

"x_y", and so "3_0" means column 4, row 1 ( index starts at 0)

if you want to start at 1, then you need 2 digit per index:

"xx_yy", "04_01" means column 4, row 1 ( index starts at 01)

then you use get substring to get to the colum or row, and convert to an int to have the index as an int, or you compose your key to get to a particular item in the grid by building a string using convert with the format ".00" so that int 1 translates to "01"

Bye,

 Jean


mekoid

  • Playmaker Newbie
  • *
  • Posts: 36
Re: How to control a 10x10 array of objects?
« Reply #4 on: December 16, 2014, 05:30:08 PM »
Great that's super helpful thanks sooooo much ;D

mekoid

  • Playmaker Newbie
  • *
  • Posts: 36
Re: How to control a 10x10 array of objects?
« Reply #5 on: December 23, 2014, 02:01:19 AM »
Thanks for the help and the amazing Arraymaker.
I started to learn it by checking the samples since there's no tut around.

Im getting to know how to make it work. But some questions remain. Such as in the "Three in a row" game. If I check one of the 9 cubes, under the "Controls", there's a "Reference". How do I get it there if I have to start from scratch??
What's the pipeline to get the "Reference" to work?

Another question is :
How do I create this 10x10 array of boards using Hashtable and make the connections between the created object and the Hashtable?

This one is my biggest issue now.
Could anyone or Jean please show me how?
Thanks so much
« Last Edit: December 24, 2014, 10:34:00 PM by mekoid »

mekoid

  • Playmaker Newbie
  • *
  • Posts: 36
Re: How to control a 10x10 array of objects?
« Reply #6 on: December 25, 2014, 04:30:30 AM »
I think I kinda figured out how Arraymaker works bascially, so the remaining question is :
I use "Create Object" to populate the array from a prefab. How can I control them thru the hashtable?
Any ideas please?
Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to control a 10x10 array of objects?
« Reply #7 on: December 29, 2014, 12:46:41 AM »
Hi,

 good. Just to confirm on "reference". It's the way you are going to tell ArrayMaker what array of hashtable you are accessing if there are multiple components on that gameobject.

 If you drop 2 arrayList on the same GameObject, then you need to tell the action which one you want to access, "Reference" will help you on this. You can also use it by default even if you have only one array or hashtable, then your system will remain solid if you have to drop another component later during development, nothing will break then.

What do you mean by "control". If you maintain an hashtable of gameobjects, then you can always get to a specific one using the hash key and then work with that object to delete it or send a event to it for example. Does that answer your question?

Bye,

Jean


mekoid

  • Playmaker Newbie
  • *
  • Posts: 36
Re: How to control a 10x10 array of objects?
« Reply #8 on: December 29, 2014, 02:15:47 AM »
Hi Jean Thanks for the reply.
I think I understand what you mean.
Just to clarify what Im doing,
1) I generate the array using "for-loop"-like process and the action "create object" based on the hashtable of a manager object.
2) The game object in the hashtable is a prefab.

So my question is even if it's a prefab, it still gets to control all the array thru the hashtable?
Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to control a 10x10 array of objects?
« Reply #9 on: December 29, 2014, 02:54:11 AM »
Hi,

 don't be confused with a prefab in your project hierarchy, that you can't work with at runtime, you can only refer to it to  instantiate a "copy" in your scene as is, that's what you are likely accessing at runtime.

 it's confusing I agree: you could have an hashtable of prefabs, that you need to keep track of, let's say, you have several ennemies, and you want to instantiate them by name, an hashtable is perfect here, during editing create a series of entries in your hashtable "enemy A", "enemy B" each pointing to the proper prefab in your project, and then at runtime, when you need to instantiate enemy A, you get the prefab from this hashtable and use "Create object" to instantiate it.

NOW, the instante you get from "create object", should be stored in a a different palce than in that hashtable, because it's not the same as the prefab itself, and so if you want to access this instante,m sotre it in another hashtable or best in an arraylist, because you are likely to have several enemies of type A, and on top of that ( bear with me :) ), if you still want to access a particular enenmy A instance  in your game,  then yes use a hashtable, and keep track of all your instanciated enemies of type + in a dedicated hashtable!

one more thing ( just to go all out on this), you can create hashtbales and arrays at runtime, so if you don't want to hardcode your storage during runtime, you can detect when you instantiate your first enemy of type ? ( A B etc...) and create a hahstable with reference "Enemy X" and so all your game becomes totally flexible, you can add a new type of enemy and you only need to add it in the hashtable refering to the different types of enemies prefabs, everything at runtime will adjust and create what's needed to keep track of all enenmies.


 Bye,

 Jean

mekoid

  • Playmaker Newbie
  • *
  • Posts: 36
Re: How to control a 10x10 array of objects?
« Reply #10 on: December 29, 2014, 04:17:34 AM »
Thanks very much for very detailed answer.
I see what you mean. So the question now is " How do I collect those runtime instances and store them in the hashtable in Playmaker? "

At this point, I might be able to pull it off duplicating the prefab as individual objects. But it's just a lot of tedious work. A LOT I mean :P
« Last Edit: December 29, 2014, 11:42:06 PM by mekoid »