playMaker

Author Topic: Testing a score against an array  (Read 1013 times)

escooler

  • Playmaker Newbie
  • *
  • Posts: 11
Testing a score against an array
« 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…..

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Testing a score against an array
« Reply #1 on: January 13, 2019, 04:39:58 PM »
You need to loop through the array using Array Get Next. 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.

escooler

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Testing a score against an array
« Reply #2 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.