I have a landscape which is essentially a 2d bezier spline. What I want to do is adopt acceleration down the slopes to add a bit of dynamics to the movement over the landscape.
What I know :
1) the position of the player on the spline
2) the height of the point of the line where the player is
3) one adjacent height value on either side (calculating any extra takes up a lot of cpu cycles)
4) the height value from last frame
What goes wrong :
Once the player has accelerated down a slope (a) and goes up the opposite slope (b), it gains acceleration in the opposite direction. Now, if I apply movement to the player (press the movement keys in addition to the natural acceleration) so that I force the player to move up the hill and over it (c) and then release the movement key, it will swing back over the top of the hill (c) from the accumulated acceleration. A not-so-good drawing:
c
/\ /
/ \b a/
/ \_/
The solution :
I need to reset the acceleration gained from sliding down slopes every time I move over the tip of a hill.
The problem :
How do I know when the player has moved over a hilltop? One way would be to keep a history of height values and if they form a pattern LGL where L is less and G is greater, set acceleration to zero, but I personally really don't like this approach (since it requires me to keep a history). Can anyone suggest a better solution based on the information presented above?
Thanks,
Crispy
Never do anything that is a waste of time and be prepared to wage long tedious wars over this principle - Michael O'Connor
[edited by - crispy on June 6, 2003 9:33:07 PM]
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared