playMaker

Author Topic: Open Level Exit When Array Value is Reached  (Read 1971 times)

Raknill

  • Playmaker Newbie
  • *
  • Posts: 20
Open Level Exit When Array Value is Reached
« on: July 05, 2016, 11:51:35 PM »
Hello there, relatively new to Playmaker so bear with me.

In my game, the player will collect an amount of objects. The objects will simply dissapear (Destroy Self) on collection, and an "Objects Collected" array will be incremented by 1.

When this array reaches a certain amount (say, 4), a Trigger is made active on the level, and upon entering that trigger the next level is loaded.

I'm having a bit of an issue in getting Playmaker to recognize the array count and check against the value. It's entirely possible I'm using the wrong action state, but I've taken a few pictures below to show my process.



In the first state, the array value is set to 0. I want to do a check in the second state, and when the value reaches a certain amount (for testing, I have that value set to 1), the trigger is made active.

Possibly of little use, but here's a picture of my Object Collectible state machine, for posterity. This has been placed on a simple sphere for now.



Thanks in advance!

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: Open Level Exit When Array Value is Reached
« Reply #1 on: July 06, 2016, 03:18:37 PM »
Hi,

As awesome as array maker is, I have to wonder if it is the right way to do this...

Unless you have other more complex features you want to use the array of collected items for, I think just an int variable and an int compare should be enough (so add to an int variable every time a object is collected and then compare the int to 4 every frame).

But in regards to the arraymaker and your screenshots, I am no expert but im pretty sure that the 'array contains' action is for checking if a specific object is in the array, although the manual is not very clear for noons when I tried to double check: https://hutonggames.fogbugz.com/default.asp?W1201

Believe it or not, I think the action you're looking for is 'array length' :D , I know great naming lol (I'm sure hardcore programmers will have a good reason for the elusive name :) ). https://hutonggames.fogbugz.com/default.asp?W1207

Then just save this number to an int and use an int compare :) .

Good luck with it, hope this helps.

Raknill

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Open Level Exit When Array Value is Reached
« Reply #2 on: July 08, 2016, 03:11:54 AM »
Great advice, using an int compare worked like a charm. I appreciate it; I guess I was overthinking things with the arrays.

Thanks again bud.

*Quick note to people whom may stumble on this; I found a great little action called "Collider Set Is Trigger" on the Ecosystem. This let me keep the collider active to block the player from exiting the level, and then when the Int Compare was satisfied, it switched the collider to a trigger, which activates the next level load.

https://github.com/jeanfabre/PlayMakerCustomActions_U3/blob/master/Assets/PlayMaker%20Custom%20Actions/Physics/ColliderSetIsTrigger.cs
« Last Edit: July 08, 2016, 03:38:42 AM by Raknill »