Wednesday, June 29, 2022
HomeGame DevelopmentUtilizing screenToWorld - Cocos Creator

Utilizing screenToWorld – Cocos Creator


Hello!
I’ve an issue with screenToWorld operate
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 unsuitable?

    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 – find out how to translate ui node coordinate into 3d world objects coordinate system?

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

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

As a result of the dice has a 100x scaling.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments