Good Morning!
On Arduino theres the Map function, it gets a range and converts it inside another range (this page shows it https://www.arduino.cc/reference/en/language/functions/math/map/ )
Is there any similar function on Construct? I want to control a object using the accelerometer, so everytime the phone is in a flat surface it gets to the middle and as you tilt it the object goes to the edges.
Thanks in advance!
Develop games in your browser. Powerful, performant & highly capable.
Offhand you can do the math directly to map x from a,b to c,d.
X = c+(d-c)*(X-a)/(b-a)
Or if you want to use some built in expressions you could do this.
X = lerp(c, d, unlerp(a, b, x))