Point and Click (raycasting) + Ortho camera

Hi,

I’m just getting started with Playcanvas. I know a fair bit of JavaScript and have dipped into Unity and Unreal at times.

I’m looking into using Ortho camera with the Point and Click example here: Point and click movement | Learn PlayCanvas

It seems that the Ortho camera breaks the code and I did read on the forums about using screenToWorld function call with the nearClip as the cameraZ parameter as the source, but I can’t seem to get it working.

Could someone help out with this, how should I amend the ray code?

Thanks,
PJ

Hey,
For the perspective mode, the point and click script is taking camera Entity position as the origin point. So for the Orthographic mode, you just have to find its origin point through screenToWorld using nearClip and it should work fine.

Checkout this project

I’ve updated that tutorial code to work with Orthographic Cameras now

2 Likes

Thank you, both! And thanks @yaustar for doing that!

@yaustar I just forked the project you amended, but it still didn’t work with an ortho camera? It did work with @saif 's project.

1 Like

Oops, my bad. I forgot to merge the changes from a different branch. Please try forking again no that I’ve merged the changes

2 Likes

Yep, all good, thanks!