I’m trying to put an element ui over an entity. So when the player presses a key it moves to where it is.
I know an element ui works in a 2d screen element and an entity is in a 3d space. So I’m using the function worldToScreen of the camera:
var elementPos = new pc.Vec3(); this.mainCam.camera.worldToScreen(this.entity.getPosition(), elementPos); this.element.setLocalPosition(elementPos);
It moves the element but it’s never over the entity, it doesn’t even cover it a bit. It’s always too far from the entity.
The green tick image should be over the cube.