You guys know I'm working on a Sonic engine for Construct, SO...
Okay, for starters, here's the current version of the engine.
Okay, so I've been trying to implement slope acceleration and deceleration, with pretty much no success whatsoever.
The Sonic Physics Guide (to be specific, this section) uses a "Slope Factor (slp)" that is used with "slp*sin(angle)" and added to Sonic's speed at the beginning of every step. The results of my attempts at implementing this method have been... Varied. The regular value for "slp", 0.125, does nothing at all. This is mainly because Construct's "Custom Movement Behaviour" works with much larger values (for example, Sonic's 'normal' acceleration is 450). Moving the decimal point around to the right once so it's 1.25 doesn't do anything either. Move the decimal point to the right again, however, and suddenly when Sonic is angled to the left he goes incredibly fast and when angled to the right he stops in his tracks, no matter which direction he's facing. Naturally, this is because clockwise from 0 degrees is positive and counter-clockwise is negative.
(Note that the default angle for when Sonic is NOT on a slope is 90 degrees. I merely reduce that by 90 when performing calculations.)
More complicated methods I've tried have not worked either. I might be doing the Physics Guide method wrong somehow, but why that would be so hasn't quite hit me yet.
If anyone could help me out, it would be very much appreciated. If any general programming guys might have an idea why I might be doing the Physics Guide method wrong, that would be awesome too.
Well, I can't help that much, but I can point in the right direction. Let me start by explaining that the behavior of being too fast to the left and stopping to the right is not correct. Look at this image:
No matter what angle value you use, you will always get the correct result. A is a 30? slope downhill to the left. B is a 30? slope downhill to the right. If you calculate the sin of the four green values (30, 150, -210, -330) it will always result in 0.5; and if you would have 30? uphill to the left or right (330, 210, -150, -30) it would always result in -0.5
If we use the slope calculation, slp * sin(angle) == 0.125 * 0.5, we get a value of 0.0625 and that value is added per step.
Now, what is a step in the original engine? Is it running at, let's say, stable 60 fps, and every step equals one frame? If so, the above value would result in adding 3.75 per second to the speed. That really isn't much, and if the speed is at something like 150 px per second, you will barely notice it.
But you said, that you raised some of the values of the original values. Be careful when doing so. Make sure, you raise them all by the same ratio. Then take that ratio and multiply it with the slope factor. For example, if the original 'normal' acceleration was 100, you used a ratio of 4.5 and your calculation would be
slp * sin(angle) * 4.5
With the example values above it would result in adding 16.875 per second instead of 3.75, which should be more noticable.
Also, if all of your movement is time based instead of frame based, while the original engine was frame based, you can't work with constant values. Instead you would then calculate the original values per second before using them. You would need to find out the frame or step rate. Example: slp = 0.125, steps per second = 60 >>> results in 7.5 * TimeDelta * sin(angle) * raisefactor
But back to my first point: If sonic is too fast to the left and stops to the right, then you're getting the wrong angles prior to the calculations. And make sure to convert all substracting and adding of angle values correctly. The original engine reversed all angles (45? are 315? in the original engine, 90? are 270?, 315? are 45?, etc. Or, in other words, they ablate the unit circle counter clockwise)
I hope, this helps a bit, I'm sorry that I explain it so complicated.