Unable to convert screen coordinate to world coordinates – #8 by Koei – Cocos Creator


@slackmoehrle I’m unable to convert screen coordinate to world coordinates.
Below is the code I have used.

console.log("screen ",touch.getLocation());
var touchPoint: Vec2 = touch.getLocation();
var worldTouchPoint: Vec3 = new Vec3();
this.camera.camera.screenToWorld(worldTouchPoint, new Vec3(touchPoint.x, touchPoint.y, 0.5));
console.log("world ", worldTouchPoint);

Below is the result I’m getting which is not the proper world coordinate. But the values I get from raycast hitpoint is proper.

What I want is pick up a object and move it around using TOUCH_MOVE.
And also is the touch.getLocation() returns double of the screen dimension, like if the screen resolution is 360×640, and top right part of the screen is (360, 640) but the getLocation() returns (720, 1280). the values are multiplied by 2. Can I know why it is like that?
Thank you



Source link

More To Explore

Share on facebook
Share on twitter
Share on linkedin
Share on email