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.
You can definitely use transparency in the custom material you’ve created:
Drag and drop your image in the Opacity channel, change the Blend Type to Alpha, select the appropriate channel (when using PNGs it would be usually A) and play with Intensity.
Oooooh the channel. That was my problem
Now it works fine. I haven’t noticed the channel was there till now XD
Thank you for your help, now everything is working. I’ve tried sth similar with raycasting but this is easier XD