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 screen 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 screen ", 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 – learn 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 all the pieces is sweet and dealing as anticipated
However I’m interested by why do I would like a mother or father node to dice with UITransform element. It doesn’t look apparent to me

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

Can I obtain display screen to world transformation with out having UITransform element on my 3d object?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments