playMaker

Author Topic: Adding Array/Hashtable Natively  (Read 7383 times)

tester

  • Playmaker Newbie
  • *
  • Posts: 31
Adding Array/Hashtable Natively
« on: November 23, 2012, 05:32:44 PM »
Could you add array/hashtable in playmaker natively? like how we create int / string variables in playmaker

It is pretty inconvenient to use with arraymaker and  proxy components.


kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Adding Array/Hashtable Natively
« Reply #1 on: November 24, 2012, 05:09:43 AM »
actually I think that's a bad idea (sorry :I ).
There are quite a bunch of important things which still need to be added to Playmaker. So I think it would be just a waste of time and already limited resources to spend time on something superficial. I do agree that some kind of integration would be great, but it should be done much later imo.
Additionally Jean's ArrayMaker really is splendid, it works very well for all purposes and makes it easy to see what's happening in game. I've used it a lot of times and whatever you call inconvenient, it is not :D (well at least not in my opinion). The proxy components are in and of themselves each a new "array-variable" and the reference is their name (Metaphorically speaking).
I do agree though that perhaps arrayMaker should be in the main build.

best,
kiriri
Best,
Sven

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Adding Array/Hashtable Natively
« Reply #2 on: November 24, 2012, 12:58:40 PM »
Hi,

 The next drop of playmaker will offer some critical improvement in Actions properties GUI which will give ArrayMaker a new facelift: basically, the actions will come down into a bear minimum amount of visible properties, and it will be a lot less scary and messy to understand, so expect a real progress on that front for a more comfortable and effective use of ArrayMaker actions.

 As for built in support for array, I think too that the amount of work would be colossal and would likely imply a complete rewrite of most of the variable interfaces and create so many problems down the road, just by thinking of it... my head is spinning. I think the great thing about arrayMaker is that the data is encapsulated into ArrayMaker proxies like Kiriri explained which makes it easier to manage because it's completly open to Unity Editor GUI which means raw power and dedicated interface without compromising any PlayMaker features. It also means direct access by other standard behaviors and scripts, so it's very verstalie and I think inline with how Unity intend developers to use gameobject's components.

 If arrays where implemented from scratch, then it would be a different story I suppose, but if you look at Unity default management of arrays in the inspector... it's very poor, and I actually think that ArrayMaker is very useful even outside PlayMaker environment. When you start dealing with arrays and lists in general, you open a very broad range of needs that can only be answered with a generic approach, which means a lot more work for the developer to implement an actual feature or function using arrays.

As for an easier way to include ArrayMaker in PlayMaker, I am planning on the following for next year (hopefully): I want to hit the asset store with a general data manager for PlayMaker, with the following trick: actions and updates would be made online ( as well as regular updates on the asset store of course), but the good thing is that I think it would be a good starting point to offer an stable and reliable way of managing data within PlayMaker projects as well as allowing the developer to pick what she/he wants from this system and just the specific actions would be downloaded, with notifications of updates, and automatic synchronisation with the project. In effect this would also be something to host all the custom actions eventually, where when you search for an action, it would also look in a database online and give you a choice of actions that you might not yet have on your project, and it would download it directly, ready for you to use it. This would include all the work I did so far on ArrayMaker, XmlMaker, CSV to XML, DataMaker and ParseMaker and few other real cool goodies that are cooking but not yet yet shared with you yet.


bye,

 Jean
 

tester

  • Playmaker Newbie
  • *
  • Posts: 31
Re: Adding Array/Hashtable Natively
« Reply #3 on: November 24, 2012, 07:32:12 PM »
actually I think that's a bad idea (sorry :I ).
There are quite a bunch of important things which still need to be added to Playmaker. So I think it would be just a waste of time and already limited resources to spend time on something superficial. I do agree that some kind of integration would be great, but it should be done much later imo.
Additionally Jean's ArrayMaker really is splendid, it works very well for all purposes and makes it easy to see what's happening in game. I've used it a lot of times and whatever you call inconvenient, it is not :D (well at least not in my opinion). The proxy components are in and of themselves each a new "array-variable" and the reference is their name (Metaphorically speaking).
I do agree though that perhaps arrayMaker should be in the main build.

best,
kiriri



There are so many things that are hard to do.
For example:
- get all game objects with name "A" and store it in array.    (you may say modify the find game object with array proxy support)
- move/scale all array game object by 10 pixel  (you may say modify all transform to support array proxy)
- an array contain a number of hash tables (you may say modify "array add" with array proxy support)
- and more..


which you are basically tell me to modify all actions within playmaker to support array, if it is what you called as "convenient".



If author is so busy on other stuff. I wish author will just release the editor source in the next release, so maybe we can code for array natively in our own build instead.
« Last Edit: November 24, 2012, 08:09:07 PM by tester »

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Adding Array/Hashtable Natively
« Reply #4 on: November 25, 2012, 04:08:22 AM »
no, the great thing about playMaker is that most actions more or less equal a certain function in a real script.

So all those things are already quite easy to do, like for the move scale you go through all the items in your list and do the transform on each every gameObject. It's how you'd do it in code so if there was an action, it would be nothing more than this all put into one action:

(I'll be using the most basic actions only, there are some like "list get next" which make it shorter)
1) Create a state where you use the "list count" action to get the total number of things. Int add -1 to get the last index(because indices actually use 0 as the first number).
2) create the "get" state. Use a new variable called "current index" which is an int and by default 0. compare if the current index is greater than the max index. If it is, exit that state into an empty one, if it's not, just do nothing. Now use a "list get" action to get the gameObject on your current index. Translate that gameObject by whatever. Then add 1 to the current index variable and either send an event or use the FINISHED event and connect it to itself (loop it).

This simple setup makes you loop through your array in a breeze and would work almost exactly like a script would. There are no functions tailored for arrays, so it's obvious that there don't really need to be any actions for this, although writing some actions is certainly time efficient in the long run.

As for your other things:
- You would never ever try to get all gameObjects of a certain name. Even looking for one gameObject of a certain name is suicide in any larger project because it actually does what we just did when we transformed everything in the array: it loops through each and every object and comparres its' name with the name you look for.

-an array that contains a number of hashtables would certainly be nice. It's also called a nested array/list. I personally do this by creating an empty, adding a proxy component and then adding that to the main array as many times as I need to. Later, I get the gameObject at a certain index, and then use get/set etc on the proxy component of that empty. It's working quite well actually.

If you think you could implement it then just contact Alex Chouls via the forums or mail, perhaps he'll let you help him, who knows :)
Best,
Sven

tester

  • Playmaker Newbie
  • *
  • Posts: 31
Re: Adding Array/Hashtable Natively
« Reply #5 on: November 25, 2012, 12:26:45 PM »
You are focusing too much on functionality without usability and scale-ability. For the use case that you provide, it works for you, It does not mean it works for most and for all use case. 

you are no different than saying "Why do we even need to multiplication 100 when we can loop adding +1."



I already tired using FSM to do all those. If you are going to do loop often, you will see you that your messy loop FSM structure, you wouldnt want to look at it anymore. It apparently increases maintainability. 

It loops through each and every object and compares its' name with the name you look for.
- it doesn't really work out when you are going to use the objects for very often use.
Altho it is a O(n) search time. It also just take O(n) space for caching, which you must have. So why not just cache it for a better way. It really depends on frequency of use.

If you are not trying to help out, Please do not try to argue if that works or that does not.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Adding Array/Hashtable Natively
« Reply #6 on: November 25, 2012, 02:18:40 PM »
Hi,

Take it easy guys  ;) I think you are arguing over different things, this will lead to nothing constructive.

One approach to all these looping is the following: use Oriented Object Approach to remove the need of a "manager" to loop through a series of object and perform a task. Instead implement that task as a behavior on the object itself. That it likely going to become a lot more maintainable and scalable.

And yes, it's true that for some specific needs, PlayMaker is not suitable, I am thinking here: Inverse Kinematics, heavy and recursive functions inside your Game Loop. Even tho, I am sure that making profiler comparison over doing it by code vs PlayMaker would give pleasant and surprising results in terms of performances: after all, PlayMaker is nothing else than c#, and what may seem like a visual penalty in terms of performance to move from one state to another, then go through actions, then back to a state and so forth, is actually likely very similar to how it would be done by script ( isolating features in methods, and calling them from a loop). If it turns out you find a very bad playmaker profiling, by all means submit it to us and Hutongs, and I am very sure it will looked at carefully and everything will done to try and reduce that overhead if indeed PlayMaker is involved.

now, @tester, all the examples you gave are perfectly fine to do in Playmaker, really. If however you encounter trouble as you try these things in Playmaker, do not hesitate to get back to us (or even to me personnaly via pm) I will gladly share with you my humble experience if it can benefit you and provide working samples and proof of concepts. I am sure your questions and apparent "frustration" ( I quote it, cause I am sure it might be simply a language barrier, remember, only very few amongst us are native english...) is shared by many as they start learning PlayMaker, or want to move from script to PlayMaker, it does require a certain shift of perspective to take full advantages of all PlayMaker wonders, yet avoiding typical pitfalls, as well as avoiding Unity own pitfalls to begin with... like Find() which I just try to avoid at all costs really. For that kind of costly functions, PlayMaker can not be held responsible, because it is to begin with a function that should be use very carefully and in full awarness of how slow it can be).

bye,

 Jean


amaranth

  • Full Member
  • ***
  • Posts: 172
Re: Adding Array/Hashtable Natively
« Reply #7 on: January 16, 2013, 10:31:36 PM »
I also would like to see arrays available as a native component. ArrayMaker is great, but it would be so much easier if I could pass an array of gameobjects between actions the way I pass a single gameobject between actions.

I guess to me, when I think of GameObject[] and GameObject, I want to see them treated in a parallel way.

I don't edit any arrays by hand, so just being able to pass them around quickly w/o looking at debug data would be a nice beginning.

I've heard that Unity V4 makes it easier to customize the editor? I haven't updated from 3.5 yet, so I've not actually seen what has changed.