playMaker

Author Topic: "Float Range Test" : Send Event if Float is Between Number A and Number B  (Read 486 times)

westingtyler

  • Full Member
  • ***
  • Posts: 248
    • View Profile
    • My Video Game Projects Web Site
Hello! I need to create a state that monitors the rotation of an object and sends different events depending on the rotation.

So I need an action that will check the rotation float and send an event if it's between number A and number B. The best way CURRENTLY that I can think of to do this with, is to do have two subsequent states with float compares. "is float above low number? if yes, is float below high number?" needless to say this means that for every angle range, I would need double the states. so if I have 10 options around a circle, I would need 20 float compare states to cover everything, instead of just having 10 "Float Range Test" actions in a single state to send their event if true.

This perhaps could be done with a Float Compare with a tolerance set at the exact center of a range, but finding this exact number for all ranges would seem tedious, since wouldn't it be easier to just set the bottom number and the top number of the range.
« Last Edit: February 22, 2019, 07:42:26 PM by westingtyler »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15050
  • Official Playmaker Support
    • View Profile
Hi,

 use FloatSwitch, you define a series of floats and what event to send for each segments.

 Can you try that and tell me if it works? the likely interesting upgrade on that action would be to only send one event per segment so that when it enters a particular segment it only send that even once until it re enters that same segment. that's if you want an Fsm running this action always and dispatch discrete events, but if you want to check once or everyframe for just a segment and move one using a transition, then you are fine.

 Bye,

 Jean