Originally Posted By: LawnmowerMan
Yes sure Kartoffel, I know you mean on all of us wink. And thank you for the code.
Yesterday, I had already made the camera moves in a given plane. To be honest I do not quite understand this formula, but I have an idea to make my own formula that will only slowly reduce the speed when camera is close to the target (if(vec_dist(camera.x,entityEND.x)<50) then camera_speed - slowdown formula). To make this formula I will try use vec_diff.
If that does not work I'll be back with new questions about formula for camera slowdown, but first I'll try to do it alone.


To get back to helping you, since this is the first time you actually proposed a snippet of your own with some sort of explanation towards the reasoning behind it:

Don't user predetermined trigger points to de-/accellerate. As we keep telling you, the answer is math. Have you learned about sinus and cosinus? Alright maybe not, but you know what a sinus curve is, yes? (In case you do not, here is a visual helper: http://3.bp.blogspot.com/-SQ_Q9OZMM1E/T-K7S0u6McI/AAAAAAAAF00/6VhU0XLwWfA/s1600/sine-curve.png )

Now do you think that in order to get a curve as such, the mathematician goes "okay now I increased by 0.1 so I need to move this over 0.1" and then does that for every point? No, of course not, if he did that the curve would neither be smooth nor would he be able to accomplish it in his lifetime.

so "the answer is math", you only need one formula which will take care of all of this, you don't need certain points at which it will do the accelleration or decelleration, math with solve this problem mathemagically (harhar).

Let's have a look at what kartoffel showed you:

Originally Posted By: Kartoffel

Here's the damn code (I dind't test it), make sure you understand it.
Code:
float p = ...; // blending percentage, range [0...1]


p = 0.5 - cos(p * 3.141592) / 2.0; // apply smooth falloff
vec_lerp(vPos_Output, vPos_Start, vPos_End, p);



You have "p", which is a percentage (as the comment indicates), only that for computers "0-100" is a bit overkill, so we use 0.0 (0%) to 1.0 (100%), you can call this a factor if you wish to do so (and quite honestly I don't know the real name for this off the top of my head, but that is not important). To make it clearer: 5% would be 0.05 and 10% are 0.1. Easy so far, yes?

You have got two points, start and end (in Kartoffel's example "vPos_Start" (vector Position start) and "vPos_End" (go on take a guess what this stands for)) and you need a vector in which the new camera position is saved (vPos_Output).

In this example, p is the percentage of how "complete" the camera is through the path, at 0% the camera is at the starting position and at 100% it's at the end position, at 50% it's exactly between those two points.

Additionally you have this wonderful mathemagic line of "p = 0.5 - cos(p * 3.141592) / 2.0;" You can find these formulae online, you don't _really_ need to understand them, but it helps if you do. The gist is, that this will take care of accelleration and decelleration for you, no matter how long the distance between the two points is. You should read into it though, it will help you in the future, sin and cos are very important for "smoothing" stuff.

Now, I don't know how much of this you understand since you don't show any willingness to try something on your own and would rather wait for someone to spoon feed you the answer, or even how much you understand after I explained the general idea to you for the same reason as before. If you had done your research you could have come to a solution akin to

Code:
float p = ...; // blending percentage, range [0...1]
vec_lerp(vPos_Output, vPos_Start, vPos_End, p);



and you would understand HOW it works and why! But you would want it to be better, like what you wanted but your math sucks, so you could have posted that and asked if someone knows a simple formula that will help you accomplish this and we would have given it to you, because we have seen that you have tried yourself and that you have put work into it and that you have grasped that basics. that the only thing lacking was your understanding of higher mathematics, which is fine! Not everyone can be an Albert Einstein, but it would have shown initiative on your part, which is all we are asking for.


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku