[Maths] Exponential function for cámera speed

J

Jeshuakrc

Guest
Hey there! I'm doing a camera muvement based on the mouse position according to the border of the camera, so, I what to make it so that while more close the mouse is to an edge of the camera, it move faster. But over the game, the point the mouse has to reach to de camera starts moving ("camera_border" as I called it) and the camera's max speed will change through levels, so I can´t use just an equation, I need someone that changes according the camera_border an de max speed. I first achieved it, but with a linear function (y=mx+b), I works well, but I want an exponential function, where the transition between show and realy fast be smooth. So I need a funtión like that: y=a*b(x), where x is the mouse position from the center of the sceen, and have to calculate a and b based on the points (camera_border,0) and (view_wview[0]/2,max_speed).

I'm not so good at algebra, and have been a whole afternoon trying to figure it out, and finaly deciced to find help here.
 

FrostyCat

Redemption Seeker
Learn how to use the regression curve functionality in spreadsheet programs, then you can calculate these yourself.
The videos show linear regression, but changing to quadratic, exponential or power shouldn't be rocket science for anyone your age.
 
J

Jeshuakrc

Guest
Thanks! I was friguring it out yesterday, and achieved the wanted resuld by:

Code:
var b = power(max_speed/1,1/(room_width/2,border))
var a = 1/power(b,border)

view_hspeed[0]=a*power(b,pos)
 
Top