[SOLVED] Is there a way to rename the topic? Someone else might find the solution helpful. Maybe.
Hello!
I'm working on a 2D platformer in java using LibGDX and over the past week I've been trying to get a good platform movement system working
So basically I have the following vectors: velocity, acceleration, friction & gravity.
What I want is, essentially the gravity being accumulated over time, not a constant gravity. (That way I can do things like, if you hit the ground with a y velocity higher than say 200, decrease the health of the player by some amount (based off of the velocity somehow).
I can do that, by simply doing: velocity += gravity * 0.01f and after one second, the Y velocity would be 240. I can then simply limit the Y velocity to say 400 to prevent the player from falling too quickly.
However, I also need to add the friction vector and when I do so, since it is higher than gravity * 0.01f it causes the gravity to become very weak.
Solution
So the solution is essentially to make sure the friction isn't too high and also only apply gravity when the player is in the air. Pretty simple.