playMaker

Author Topic: [SOLVED] Float between  (Read 4049 times)

gozda

  • Junior Playmaker
  • **
  • Posts: 88
[SOLVED] Float between
« on: December 28, 2014, 02:49:38 PM »
Hello.

There is action where can i set when float is between -90&0 and 0&90 then send to event?
« Last Edit: December 30, 2014, 07:10:33 AM by Lane »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Float between
« Reply #1 on: December 29, 2014, 01:41:20 AM »
Hi,

 Yes, use the "float compare" action. Have you tried this already?

 Bye,

 Jean

gozda

  • Junior Playmaker
  • **
  • Posts: 88
Re: Float between
« Reply #2 on: December 29, 2014, 02:36:09 AM »
Yes i tryed float compare work almost fine but i can only make when float is greater than 90 or less than -90. I want make when my float is in value between -90 and 90.
It is possible?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Float between
« Reply #3 on: December 29, 2014, 03:08:00 AM »
Hi,

 yes, simply inverse the logic.

first action: compare with -90 and only fire an event "OUT OF RANGE" if smaller than -90
second action: compare with 90 and only fire "OUT OF RANGE"  if greater than 90

now, if you are still in the state, it means your float is within -90 and 90, and use a send event action "WITHIN RANGE"

this kind of logic implementation is very important to understand, it's very powerful, it's often use in math to prove a theorem. If you can't prove it's possible, you can prove also that's it's impossible not to be :) almost philosophical !

if you can't prove it's between -90 and 90, prove that it's smaller than -90 or greater than 90 which then must be between -90 and 90.

Bye,

 Jean



escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Float between
« Reply #4 on: December 29, 2014, 03:10:17 AM »
You could have one state with 2 actions, the first, float compare - if it is less than -90 it will send 'notBetween'. The second action would compare it to 90 and if it's greater it will send 'notBetween' if it passes both of those actions it would send the FINISHED event which would mean it is between.

EDIT - Jean beat me to it :P

gozda

  • Junior Playmaker
  • **
  • Posts: 88
Re: Float between
« Reply #5 on: December 29, 2014, 04:21:37 AM »
I am using action delta angle euler(or something like that) this give me angle from -180 to 180. Its calculating position between 2joys and give me negative or positive angle. And i already created 2 float compare if angle is more than 90 or less than -90 and send to another state. But what if i am in next state and angle will be between -90 and 90? If i will create in 2nd state float compare when angle will be less than 90 and greather than -90 this give me a error becouse -140 is less than 90 and game stop.

An idea. tell me if this will work
I will take position of 2 joys and inverse thier position by multiply -1. And this give me inverted angle, in place where i have angle 0 this give me +-180. And in this state create the same float compare what in 1st state, This will be work?
« Last Edit: December 29, 2014, 04:24:24 AM by gozda »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Float between
« Reply #6 on: December 29, 2014, 07:39:05 AM »
The state flow of action logic is top to bottom, it sounds like this is something you can do in one state.

1..Float compare (>90)
[Fire Out Of Range Event]
2..Float compare (<-90)
[Fire Out Of Range Event]
3..Send Event
[If it made it to this action, then the value is in range, Fire In Range Event]

However you should be able to do the same thing with Float Compare and setting the tolerance to the allowable range, which is 180 for value between 90 and -90.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Float between
« Reply #7 on: December 29, 2014, 09:10:49 AM »
Hi,

 Clever the use of the tolerance! never though about using it for such a large range :)

 Bye,

 Jean

gozda

  • Junior Playmaker
  • **
  • Posts: 88
Re: Float between
« Reply #8 on: December 30, 2014, 04:10:12 AM »
Lane solution works great.

Thanks all for help.