long currentFrameTime = System.nanoTime();
float deltaTime = (currentFrameTime - lastFrameTime) / 1_000_000_000.0f;
lastFrameTime = currentFrameTime;
float nextForceSlide = forceSlide - forceSlideDecreaseRate * deltaTime;
if (nextForceSlide < 0) {
forceSlide = 0;
} else forceSlide = nextForceSlide;
game.physicsEngine.updatePosition(this, game.joyStick.angle, forceSlide * deltaTime);
public void updatePosition(Entity entity, double angle, float length) {
entity.position.x = entity.position.x + length * (float) Math.cos(Math.toRadians(angle));
entity.position.y = entity.position.y + length * (float) Math.sin(Math.toRadians(angle));
}
This is how i try to add a little force to the player into the direction where it is currently looking at. Since i want to support 30 60 120 fps the result of the applied force should be same for each. But right now it feels jittery not smooth when the player is sliding. Why?
I try to add a little force to my player when it is sliding after a jump movement. Currently it feels very jittery. I expected it to be smooth.
New contributor
E Y is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.