Screen xy to world coordinates

apologize if looking in the forum I have already missed the answer to the question I’m about to ask

Someone can give me a concrete example of how to use Vector3 Unproject, to convert screen xy coordinates into world coordinates?

thank you in advance for any help!

Hey and welcome back!

here is how to use it:

        var vector= BABYLON.Vector3.Unproject(
                        BABYLON.Matrix.Identity(), scene.getViewMatrix(),

Thank you @Deltakosh!: )

the scenario is to set the position of a mesh.
Before I used the pickedPoint with this.scene.pick(this.scene.pointerX, this.scene.pointerY)

Does using Vector.Unproject way give the same results?

yep :slight_smile: mousePosition is your pointerX/Y thingy


Hi and thanks for a great product.

I would like to add - make sure your (input) mousePosition.z is set to 1 to get the expected results

I have been lurking for a while - writing a racing game … about 8 weeks in - thought I would try and make a positive contribution


Hey and welcome!!
Please share your game when you want :slight_smile:

Will do … although it is nowhere near as far along as the Need for Speed demo…

It’s a top down, racer with custom physics (mass spring system)… I am focussing on high frame rates and smooth gameplay, with analogue input (gyro, accelerometers, mouse) for a nice driving feel… cross platform obviously. I have one commercial game under my belt written with Direct X ( but it is hamstrung by being PC only in an increasingly mobile world.

Lots to like about Babylon, have hit a few performance issues but nothing insurmountable, subdividing meshes should help, but that has broken picking at the moment, so I need to work out how to find the submesh from the subdivided mesh with ray picking … will ask more clearly if I get really stuck.

Very impressed by your dedication the the cause, I hope I can build something that does it justice.


Feel free! We are here to help

Hello everyone,

I am (I think) in the exact same issue. I need to add a sphere where the user clicks. I tried the following option :

var ballPos = BABYLON.Vector3.Unproject(
new BABYLON.Vector3(scene.pointerX,scene.pointerY,1),
BABYLON.Matrix.Identity(), scene.getViewMatrix(),

But the coordinates are really weird (like thousands or so)…

I thought about an option where I link a transparent plane end get the picked position but it’s seems a bit goofy.

Any idea ?


OK I think I have found the solution here : Scene.pointer to Vector3


Having same trouble here. Any help appreciated.

1 Like

is this one not working Scene.pointer to Vector3 - #2 by Cedric ?

Hi @trsh do you still have trouble?