If the main camera add a render layer

I add a custom layer to main camera. then the screenToWorld function return a wrong direction.
In fact this custom layer is useless for me, but I just wanna know the reason why it’s will make the function gives a wrong direction?

Hi @ZipZapWxh,

It shouldn’t happen, this method shouldn’t be affected by the layers the camera is rendering to.

Are you able to to provide a sample project that reproduces the issue? Sounds like a bug if that’s the case.

Here is the function signature:

Emmmm… Maybe I cannot provide the project to you cause I already changed a lot of code. But I can make some screen shots about the layer , camera and code for you .

Yes, what would be useful then is if you can post the steps that reproduce the issue. To try and replicate this on a project of mine.

The culprit is layer(Minimap).
Maybe my layer setup is wrong.

Try reloading your launch window after you add/remove layers.

Yes. I already did it. this bug torture me for couple of days.

If you find this is a showstopper for you app and seems like a Playcanvas bug, try to create a simple project that reproduces the issue.

Not sure I can do that out of context given that info, but if you can provide that we can easily debug it.

Sure.There is a template project : https://playcanvas.com/editor/scene/893865
I am missing some steps before, there are two camera , one for main camera another for render to texture.

Thanks @ZipZapWxh for providing this.

What are the steps to reproduce the issue?

  1. Clicking on the cubes works, when launching the app (camera moves from one cube to the other).
  2. Removing the Minimap layer, clicking to move still works.
  3. Adding back the Minimap layer, same behavior, clicking to move works.

Did you find something unusual? I can make some changes for you.
https://launch.playcanvas.com/893865?debug=true
The white box’s position is the raycast result.point

Mmm no, the white box is positioned correctly both with the Minimap layer added to the camera and without it.

Does it work like this for you as well? Everything seems to be fine.