Attribute range expression
Lokitoes
Member, PRO Posts: 187
Hi guys,
I am working with accelerometer and want something to happen when it is within particular ranges.
For the expression, I want to say things like "when accel x is between +7 and +9, do this". Currently I just have this written in the expression window but I have no idea if this is ok or not?
And what if the range is between +3 and -3, or -3 and -5, not just plus values? Then the kind of simple expression that I have here wouldn't seem to apply anymore - how would I write it then?
Thanks all!
Comments
you can add multiple conditions. do two with < and >
Thanks adent42! Sorry to be a pain, but is this, below, what you mean? (I would just test it but when accel I have to export it every time to test it so it's slow going). Would that put it between 7 and 9?:
Or can I do this to also include those numbers?:
@adent42 Sorry I just realised how dumb I am and that the symbols are already in there. Another quick question: can the accel attribute do decimal points?
Yes. I recommend adding some Display Text behaviors with accelerometer values and then testing on a mobile device so you can see what types of values you get.
Also, @jamie_c has some terrific tutorials, accelerometer included: https://www.youtube.com/watch?v=JzluQc2XIiA
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks tatiang! You know, I was using a separate app to check the accel parameters (one of those apps that shows you the different physics tools of your phone etc) and thought I had it all sussed and didn't need the display text for the values. But when I put in the display text, I realised it was a completely different decimal point range to what the other app was displaying. I guess that is a lesson learnt for the future. :)
Actually I said that so confidently and just made a spawnable actor that should technically be 'impossible' to spawn because the phone has to go outside the normal accelerometer value range in order to spawn, and after a few tries it somehow spawned... So maybe I still don't quite understand the values 😅oh well it's trial and error!