playMaker

Author Topic: Math/Boolean workflow question - number inside range? [SOLVED]  (Read 2217 times)

Maicus

  • Playmaker Newbie
  • *
  • Posts: 2
I'm making a 3D game that uses 2D sprites for characters.

I'm working on a system that takes the angle between the main camera and a gameobjects x vector, and switches out sprites depending on the angle.

I'm proficient in grasshopper and a few other visual coding languages, but I don't really have a strong grasp of playmaker.

How would I got about checking an angle being in one of a number of ranges?

E.g. 1-90, 91 to 180, 181-270, 271-360 (degrees).

From there I planned to send off an event that changed the sprite, but I can't work out how to set up the initial logic.

Cheers in advance,
Chris
« Last Edit: August 25, 2013, 08:29:41 PM by Maicus »

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Math/Boolean workflow question - number inside range?
« Reply #1 on: August 25, 2013, 05:48:40 AM »
If you have the vector its rather simple -

Create a state with these states (in this order) has 4 events 0-90, 91-180, 181-270, 271-360

Float compare - float 1 = vector float 2 = 90
Events - Equal = 1-90, Less than = 1-90, Greater than = none,

Float compare - float 1 = vector float 2 = 180
Events - Equal = 91-180, Less than = 91-180, Greater than = none,

Float compare - float 1 = vector float 2 = 270
Events - Equal = 181-270, Less than = 181-270, Greater than = 271-360,

This is assuming the returned float is between 0 and 360

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4003
  • Official Playmaker Support
    • LinkedIn
Re: Math/Boolean workflow question - number inside range?
« Reply #2 on: August 25, 2013, 02:34:46 PM »
You can also use Float Switch to set up the ranges (should be quicker to setup).

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Math/Boolean workflow question - number inside range?
« Reply #3 on: August 25, 2013, 04:53:37 PM »
Float switch! It's crazy that Ive been using Playmaker for over a year and there is still so much to learn. I think sitting down and going through ALL the actions could be a valuable task.
« Last Edit: August 25, 2013, 10:00:09 PM by LampRabbit »

Maicus

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Math/Boolean workflow question - number inside range?
« Reply #4 on: August 25, 2013, 08:28:57 PM »
Cheers guys. I knew it'd be something simple! ...it's an interesting mindset trying to get into, thinking in states. Very powerful tool though.

Thanks again,
Chris