Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: escooler on January 13, 2019, 09:38:05 AM

Title: Testing a score against an array
Post by: escooler on January 13, 2019, 09:38:05 AM
Hey playmaker folk,

Got really stuck on this problem and don't know how to approach it at all; a short explanation of the situation and then the problem;

The game generates 20 candidates each with their own score, I am storing all these scores together in an array. As the game plays the player can select any one of the candidates as they come past.

Now for the tricky bit; once the player selects as a candidate I want to measure how they did, how many better candidates there were and how many worse….not sure how to go about testing the value against the other candiates…..
Title: Re: Testing a score against an array
Post by: Alex Chouls on January 13, 2019, 04:39:58 PM
You need to loop through the array using Array Get Next (http://"https://hutonggames.fogbugz.com/f/page?W1205"). There's a simple example in the docs if you click on that link.

I also put together a little example to show how it works in your case. Import the unitypackage and paste the General/ScoreCandidates template as a new FSM on a GameObject. Set the Picked Candidate index, and when you run the FSM is should count NumBetterCandidates, and NumWorseCandidates. Hopefully, the variable names are self-explanatory, but let me know if you need help deconstructing it.
Title: Re: Testing a score against an array
Post by: escooler on January 15, 2019, 05:37:49 AM
Amazing, thankyou, I will take a look at this, I have been having trouble working out what works ect as I am fairly new to programing.