LibGDX - deltatime?

3d Object moving on my second phone is faster.

I tried this here:

    if (deltaTime > 0.1f) deltaTime = 0.1f;

But this don’t works.

How can I do it, that the render() has the same speed on all phones?

I thought, that LibGDX regulates the deltatime self.

Well you can’t really adjust deltaTime like that that is not how it works…I’m not sure if this will help but here’s an idea:
If you have some object with an x and y position, you would do it like this
To increase the x coordinate:


final int speed = 100;
x += Gdx.graphics.getDeltaTimer() * speed

Yes, I know this, but is it not possible to do this without to add the deltaTime to the movemet variable?

My project looks like this:



public class ObjectScreen implements Screen {
	Game game;


	public ObjectScreen (Game game) {
		this.game = game;
		
		cam = new PerspectiveCamera(45, VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
		...
	}
...

@Override
public void render (float delta) {
	update(delta);
	draw(delta);
}

public void update (float deltaTime) {
	// ...
}

public void draw (float deltaTime) {		
	if (deltaTime > 0.1f) deltaTime = 0.1f;

	GL10 gl = Gdx.graphics.getGL10();

	gl.glClearColor(0.0f, 0.0f, 0.0f, 1);

	gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
	...
	
	// 3d Object moving
	...
}
}

deltaTime: [quote]Returns:
the time span between the current frame and the last frame in seconds. Might be smoothed over n frames.
[/quote]
Based off of that and understanding how that works, editing that variable (if you can do that) will not exactly solve your problem…Is there any problem with using the example i provided?

Your logic…is pretty off :clue:
As wreed correctly said, delta is the time between frames. You multiply your movement variable by that, so stuff will more slower when the game loop runs more, and faster when the game loop runs less. Otherwise your movement code will not be kept in check with the game loop and instead will vary with the speed of the computer - for example slower computer can only run @ 30 fps, movement will be half as fast, will break gameplay for most games.

Treat delta as your system resource, as it is resource to begin with. It is feedback from outside. So your system has to deal with it and take appropriate action.

I understand deltaTime now better. Thanks.