playMaker

Author Topic: Array List Contains (scriptable objects) never true [SOLVED]  (Read 3170 times)

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Array List Contains (scriptable objects) never true [SOLVED]
« on: March 14, 2018, 02:14:21 AM »
Similar to this thread: http://hutonggames.com/playmakerforum/index.php?topic=15832.msg73624#msg73624

I have a problem to make 'Array List Contains' work with my scriptable object.

Here is the FSM:


I can't get the "contain" to become true. I add "ItemBuilding" Objects to the Array List, they show up when I run, so I know it fins the Item building object in the array. Not sure if it's connected, but the Array List Proxy in the inspector doesn't show objects, it just count up the "content" number.

It seems to work when I use normal gameObjects/prefabs though. Am I overlooking something or do I need to use another approach? The scriptable Object is containing the data and when a new inventory item has been added it creates a item prefab and apply the data.

Any help much appreciated!
« Last Edit: March 16, 2018, 06:26:57 AM by DanielThomas »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Arraymaker List Contains (scriptable objects) never true
« Reply #1 on: March 14, 2018, 02:29:14 AM »
Hi.
One thing i can see is that on the 'Create Item' state, next frame event is above the Set property, which means it will be called before Set Property.

Also you should set the 'Create Item' state as sequence

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Arraymaker List Contains (scriptable objects) never true
« Reply #2 on: March 14, 2018, 09:50:09 AM »
Ah yes, it's just WIP, the item creation is working and it does create the item with the scriptable object that is in the array list, just can't get the "contains" to work, so it doesn't add more of same item but just add to the "amount" of the gameObject that is already created.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Array List Contains (scriptable objects) never true
« Reply #3 on: March 14, 2018, 04:28:02 PM »
Hi.
Try setting some breakpoints on the states (right click on the state name and click Toggle Breakpoint)
And then play it to see what is happening step by step.

And look if you did get a result (arrayItem) from the 'Array List Get Next'


DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Array List Contains (scriptable objects) never true
« Reply #4 on: March 14, 2018, 05:52:58 PM »
I'm not sure what is going on. It works if I set a breakpoint at the "already have" state. If I remove the breakpoint it doesn't. I tried to set a state with wait 1sec before and after to see if it was not getting it in time or something. The thing is, even when the "contain" return false it still creates the correct object (so it does have the correct object in the testing index).

I'm probably going with an inventory system solution from the asset store as this probably will get too messy for me in the long run. Would still be good to know what the problem causing this is.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Array List Contains (scriptable objects) never true
« Reply #5 on: March 15, 2018, 02:28:32 AM »
Hi,
The 'Store Array List Name' is this an action you made, or did you rename a get property action?

try to place a next frame event state after initiate. (so between initiate and inventory changed)

Maybe you could name the object same as the Reference (on the array list) and use 'Get Name' on the gameobject.

I can have a look to it if you want (you can pm me a link to your project or use collaborate)

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Array List Contains (scriptable objects) never true
« Reply #6 on: March 15, 2018, 04:02:29 AM »
'Store Array List Name' is a get property from the gameObject.
I made it work with putting a wait in the "contain" action state. So not sure why? But either way it works, thanks for the help!