Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - SamH

Pages: [1]
PlayMaker Help / Convert Array to Playmaker Array List
« on: August 17, 2021, 06:58:21 PM »
Hey there, I'm using a 3rd party plugin to detect gameobjects in view. It has playmaker support and has an action to save all detected objects to a standard unity array. Does anyone know of any playmaker actions that will convert an array into a Playmaker array list?
I know I can loop through the array and add the items 1 by 1, but anyone know of an action that will do this in a single step?


PlayMaker Help / Optimization when dealing with high numbers of FSMs
« on: January 23, 2021, 01:56:26 PM »
Hi there, I have some questions related to FSM performance and optimization hopefully someone can give me some guidance on!
My project involves a prefab NPC (just a single 2D sprite) which has a FSM containing around 100 states (all pretty simple actions that control a schedule the characters moves through- eg navigate to bar, wait, navigate to roof, wait, etc). As the game progresses the amount of these NPCs increases into the hundreds, sometimes over 1000 simultaneously. Everything is working great (playmaker has been incredible), but it does get to a point where it starts crashing on iPhone- I'm guessing its just running out of memory.
I have been through all the actions and optimized heavily based on tips in other threads:
-No 'find object' or other expensive actions
-No 'every frame' style actions.  etc

So... a question specifically about the FSM component itself, as I realize there might be some opportunity for broader optimization. The NPCs go into a waiting state for 5 minutes at each location they visit. This is just a single state with only a 'wait' action inside it. But of course the entire FSM component is still 'active' (containing the 100 states and 20 or so variables).. is the rest of this FSM taking up a 'cost'? Or is the current state it is in the only relevant thing here?

Optimization ideas:

1. I thought maybe instead, when the NPC enters their wait state, they could send an event to a new FSM which only has 2 states in it, a wait state and a 'return to active' state. This wait state could deactivate the original larger FSM component for those 5 minutes, then when complete, it would reactivate the main FSM component and return it to previous state. Thus the majority of NPCs on screen would have inactivate FSMs at any given moment -Would having the FSM component deactivate actually help though?? Or is activating a small FSM when deactivating the original large FSM having a 0 net change.

2. Does deactivating array/hash list proxy components when not being used help at all? Each NPC has a few of these that they use only at certain parts of their schedule.

3. Instead of deactivating the FSM component, would deactivating the whole object be a bigger saver? I could replace my NPCs with a static sprite when they are in their 5min wait state.

Any small optimizations multiply out massively as the NPCs increase. So any guidance here would be amazing!

I wasn't able to find any other reports of this issue, so let me post it and see if anyone else has experienced this.

Occasionally when I have worked on a prefab object FSM (by double clicking on the asset and opening it up in its own scene), I will save and return to my main scene file to find that some of the variables in the instance of the prefab have been jumbled up.  ie 'Int_Variable_A' inside an action has been switched out for 'Int_Variable_B'.   If I return back into my prefab scene, all the variables there are correct. Jumping back into my main scene file again, they are still jumbled.

Note this is not an issue with me overriding values on an instance of a prefab in my main scene file. This happens even if the prefab doesn't exist at all in the main scene hierarchy (and is created freshly by a playmaker 'create object' action after hitting play).

Some additional info:
-When the issue occurs it will soemtimes jumble up lots of different variables in a few states and actions.
-As the variables are switched randomly, 'luckily' it breaks my scene so catastrophically that its usually very apparent that the issue has occurred so I know to look for it.
-Its pretty infrequent that I get this issue.. but does pop up every few days
-The mix up does persist into a build of the game. Its not just an issue in my unity scene.
-Weirdly, if I change the problematic variable in my action (in the prefab file) to something else, save, then change it back to the correct variable and click save it does NOT correct/refresh the problem in my scene file.
-Luckily though I do have a very easy fix. If I create an empty state in my prefab FSM, click save, then delete the empty state and click save again, when I return to the main scene file this completely resolves the issue.

In my screenshot 'Prefab' You see the correct variable 'FloorManager_go'.
In the screenshot 'SceneInstance' you see what this same action looks like on the instance of the prefab- 'Current_Money_go' is in its place. Which is another random variable which was in use somewhere else in the prefab.

Sorry I don't have any exact repro steps to reliably reproduce it.. but I did make a video of the issue last time I saw that which I can provide if it helps.  Thanks!

PlayMaker Help / Touch Controls in Playmaker - help needed!
« on: May 14, 2020, 12:15:11 PM »
Hi all, does anyone have any solid experience implementing touch controls with playmaker? I'm very familiar with playmaker but touch controls are new to me.
I feel like I just need to get off the ground with the basics and then I can take it from there. I'd be willing to pay for someones time if you'd be interested in an hour or two of assistance!

I only need to learn the basics:
-pinch to zoom (specifically being able to zoom accurately in on the pinch points)
-Touch and drag to navigate around a 2d screen
-Making camera movements hit defined screen boundaries (whether dragging or pinch zooming)

Currently I have basic taps working (as the mouse click commands translate easily to touch controls and are thus also easy to test in game view via mouse clicks).
I also have a few custom actions like 'Camera Pinch Zoom' and 'Drag Camera' which functionally do what I want but I haven't been able to make them feel responsive the way touch needs to be.
I also bought EasyTouch5 which has playmaker support, but with their forums down I've struggled to make progress there.

I'm sure that with some initial assistance I'll pick this up quickly! Please let me know if anyone can help me out!


Let's say I have a hash table (using array maker) that contains 10 people (keys) with a bool value that represents whether or not each one is wearing a hat.

Of all the people (Keys) in the table, I would like to select one that is wearing a hat (Bool is true) at random.


I've been going in circles with this one.. I did find a work around but I'm curious if anyone has a simple way to do this that I'm missing..

Lets say I have a scene file which has a bunch of cube objects which are all identical prefabs. Each has a playmaker script which shows and hides a group of GUI text objects (which exist in the scene not the prefabs) when clicked. I'd like the all the text to be hidden by default, and only activate when a cube is clicked.   Prefabs can't directly reference scene objects, so I need the prefabs to reference a game object variable to interact with my GUI.

What I attempted:
1. I started with putting a FSM on a group which holds all the the gui text objects. It does a Find Object and declares itself as a global game object. I have the group de-active so they'd all be hidden at the start, waiting to be activated. This doesn't work because the deactivated game object doesn't run the FSM so it doesn't get found and stored in the global variable. (and if I use this method for all prefab interactions im gonna end up with a ton of globals=bad)

2. Next I tried making the group active by default. I made each prefab do an initial setup state where they each do a Find Game Object (using a tag on the gui text group) and store as a local variable. Then they instantly deactivate that group so its hidden. This doesn't seem to work (the variable comes up blank) I think because one of the prefabs is finding it and deactivating it a frame or so before other prefabs are finding it. Meaning the game object is not reliably found by all my cubes. Its also not great because I potentially have  a frame or two where the text is visible on screen before popping off.

3. I now realize that its probably a bad idea to be using the 'activate' feature, because it deactivates all the scripts potentially running on that object and it also has the above problems with not being able to be found. So I feel like its better to just activate/deacivate a sub property, like the Text(Script) or the canvas. So this element can be hidden by default but allow the top node to stay active. So I firstly find the gameobject in the prefab. Then I add a 'set property' action to my prefab FSM. BUT it doesn't look like I can use any global or local gameobject inside this action, which means prefabs are unable to use this action to interact with anything outside its own prefab.

So.. whats the best way to achieve this? It feels like there should be some 'hide' option which just makes the object invisible but keeps it (and any scripts on it) activate. The 'Set Visibility' action for some reason doesn't seem to work on my gui text.

My workarounds (none of which I like):
-Use a 'set text' to just remove the letters instead of hiding. But this wont work with say a GUI image
-Translate the GUI off screen and back on again. (This doesn't feel like a sensible way to handle it though..)

-Lastly what I've ended up doing is to have each prefab find the text group locally, wait for .1 of a second to ensure each instance has enough time to find it, then deactivate the group. It works but its not ideal.

Any help would be greatly appreciated!
ps playmaker is incredible.. loving it

Pages: [1]