Tuesday, June 28, 2022
HomeGame DevelopmentUtilizing screenToWorld - Cocos Creator

Utilizing screenToWorld – Cocos Creator


Hello!
I’ve an issue with screenToWorld perform
I need to get place of my click on on display after which transfer my 3d node to this place
However I’m getting the identical values with occasion.getLocation and screenToWorld (utilizing canvas digicam)
What am I doing improper?

    console.log("display ", occasion.getLocation());
    var touchPoint: Vec2 = occasion.getLocation();
    var worldTouchPoint: Vec3 = new Vec3();
    this.digicam.digicam.screenToWorld(worldTouchPoint, new Vec3(touchPoint.x, touchPoint.y, 0.5));
    console.log("world ", worldTouchPoint);


What precisely my query is – tips on how to translate ui node coordinate into 3d world objects coordinate system?

you’ll be able to consult with :
Creator3.4.2_ScreenToWorldPoint.zip (7.9 KB)

Hello linrm!
Thanks for instance
Now the whole lot is sweet and dealing as anticipated
However I’m interested in why do I would like a mother or father node to dice with UITransform part. It doesn’t look apparent to me

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments