
Let’s set the position to be 2.5 so it can sit just above the player’s head. Next, we’ll add a new Child Node to the Player node ( Ctrl+A) of type Camera. We’ll also set the Y translation to 1.25 so that the collider just sits above Y zero. We’ll set the rotation degrees to 90 on the X: Select the Capsule in the Inspector, and set the Radius and Height to 0.5 and 1.5, respectively. In the Inspector panel, we can set the Shape property to ‘ CapsuleCollider‘. Next, add a child node ( Ctrl+A) of type CollisionShape. We’ll rename the node to “Player” and save it as “Player.tscn”. For more information, visit the documentation:

It also has a built-in API for moving objects. KinematicBody is a type of body that is not affected by physics, and it can only be moved by code or by an AnimationPlayer. Go to Scene > New Scene.Ĭlick on ‘ Other Node‘ and create a new Root Node of type KinematicBody. Import .viewport.In this lesson, we’re going to create our player object. Import .lwjgl3.Lwjgl3ApplicationConfiguration Here is a SSCCE (or an MCVE) based on the code in the LibGDX wiki: import In a matter of seconds it increases to something like 334756315000. As far as I know, this should lock the camera to actual screen coordinates, not fractions thereof.įor some reason, however, the y value of the new position just explodes.


After that convert it back to world coordinates and use that as the new camera position. Now what I tried was this: Move the camera, project the current position (so it's screen coordinates) and then round or cast to int. (Is there a better term for that?) Note that this is a pixel-art game where I want to have crisp pixelated graphics.

Basically I want to stop the camera from moving in subpixels, as I think this leads to sprites visibly changing their dimensions if just ever so slightly.
