A
A
alkolove12018-08-04 09:42:42
Java
alkolove1, 2018-08-04 09:42:42

How to roll a billboard in LibGDX?

A sprite is a decal in 3d space. It is always facing the viewer
motoSpr.lookAt( MyGdxGame.cam.position,MyGdxGame.cam.up);
As soon as I specify after this line motoSpr.setRotationZ(angle) (X,Y are responsible for the rotation towards the camera), so the rotation values ​​​​to the camera are reset (X,Y included).
For the sake of experiment, I wrote it down like this motoSpr.setRotationZ(motoSpr.getRotation().z); and what do you think? Anyway, the value was reset, and the sprite does not look towards the camera, but by default.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lgorSL, 2018-08-17
@lgorSL

Here is the source code on the github
setRotationZ does not rotate only around Z, but specifies a new orientation, which is a rotation around the Z axis.

public void setRotationZ (float angle) {
    rotation.set(Vector3.Z, angle);
    updated = false;
}

If you want to modify an existing position, you can try this method:
public void rotateZ (float angle) {
    rotator.set(Vector3.Z, angle);
    rotation.mul(rotator);
    updated = false;
}

It rotates the sprite around the Z axis.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question