playMaker

Author Topic: [Help] Array Contains action doesn't seem to work.  (Read 2643 times)

joshua121

  • Playmaker Newbie
  • *
  • Posts: 6
[Help] Array Contains action doesn't seem to work.
« on: September 23, 2017, 08:03:31 AM »
I'm using the corgi-engine inventory system and I am trying to check the inventory for an object.

I'm using a "Get Property" action on the inventory and storing the result as an object array, then I'm trying to use an "Array Contains" event to check to see if the item is in the array.

I can see that the object is in the array, but the "Array Contains" action is staying false, I"m not sure how else to do this or what is going wrong.

Any ideas?

Thanks in advance.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: [Help] Array Contains action doesn't seem to work.
« Reply #1 on: September 23, 2017, 10:24:08 AM »
Hi,
I think there might be an object type issue there
On the Get Property on the object type you can see the type = MoreMountains.InventoryEngine.....

In the array contains on the value i can see (inventoryEng...

So it does not start with MoreMountains.

is this corgi-engine inventory system on the asset store?

Can you give a link.

Deek

  • Full Member
  • ***
  • Posts: 133
Re: [Help] Array Contains action doesn't seem to work.
« Reply #2 on: September 23, 2017, 10:50:16 AM »
It might also be that you get the content every frame, while Array Contains only runs once when entering the state; so if you add your Items like tShotgun later on to the Inventory, Array Contains has already finished running.

If so, your best options would be to send a global event to this state when you add Items to your inventory or simulate running this state every frame by sending an event to another state in 'Is Not Contained Event', in the other state have a "Wait" action with like 0.1s or 0.01s delay and connect it back to this state.

joshua121

  • Playmaker Newbie
  • *
  • Posts: 6
Re: [Help] Array Contains action doesn't seem to work.
« Reply #3 on: September 23, 2017, 01:43:32 PM »
Hi,
I think there might be an object type issue there
On the Get Property on the object type you can see the type = MoreMountains.InventoryEngine.....

In the array contains on the value i can see (inventoryEng...

So it does not start with MoreMountains.

is this corgi-engine inventory system on the asset store?

Can you give a link.

Hi DjayDino, the corgi-engine is on the asset store, https://www.assetstore.unity3d.com/en/#!/content/26617

it includes the inventory engine which is also available separately.
https://www.assetstore.unity3d.com/en/#!/content/95550

I'll include a screenshot of what the item/object looks like in the inspector too.

I went into the FSM and changed the object type to MoreMountains Inventory Item, but it's still not working.


Hi Deek,

I tried looping the FSM to see if you were right, but it doesn't seem to have any effect. It loops but still never finds the item in the inventory.


What I'm trying to do is find out whether or not the player has the item in their inventory, so that if they do, I can disable the pickup for it.
« Last Edit: September 23, 2017, 02:09:35 PM by joshua121 »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: [Help] Array Contains action doesn't seem to work.
« Reply #4 on: September 24, 2017, 12:53:34 AM »
Hi,
Its probably because on the 'contains' action you are using the prefabs so the type will be gameObject.

I don't have the asset, so i can not test this.

Maybe you can ask the author if he would want to support playmaker in his asset and you can let him contact me if he needs help with it.