Ray Cast issue in Mobile

I have made a test project where if I click on aim and drag it on the surface, it should move.
It is working alright on PC browsers but on mobile, it is not working as expected. in “on touch move”, somehow it cant find the raycast result continuously but it does once in “onTouchStart”.

Project Link: https://playcanvas.com/editor/scene/1230825
Published → Raycast Test - PLAYCANVAS

Hi @Faisal,

Your _onTouchMove callback works but it returns an array of gestures, not x,y coordinates directly.

You need to grab a gesture, in this case the first one and get the coordinates from there. Then it will work as expected:

MoveEnvironmentAim.prototype._onTouchMove = function(event) {
        var touch = event.touches[0];
        var from = this.mainCamera.getPosition();
        var to = this.mainCamera.camera.screenToWorld(touch.x, touch.y, this.mainCamera.camera.farClip);

Oh what a basic mistake,
Thank you so much for helping

1 Like