nogalo Posted October 26, 2018 Share Posted October 26, 2018 Hi. I am visiting this forum a lot because i recently started working on several projects using babylon.js am absolutely in love with it. This is my first post/question ever tho and I hope you can help me. Also, I put "VirtualStoreProject" in the name because I believe I will have a few more questions during this so I want to I started working on Virtual Store project, and I created proof-of-concept page just to try some things out before going into the real work. Here is a link to that (looks awful at the moment I know) https://www.productexample.com/virtualStore/virtualStore.html Now what I want to achieve is when I click on the mesh, that mash moves toward the center of the camera view. For now the implementation is not very fancy targetPosition = new BABYLON.Vector3(camera.position.x+20, camera.position.y, camera.position.z); and this only looks okay if you are looking straight at the mesh and you are not too close to a wall in front of you (in case you do, the mesh goes outside). Another question I want to ask is if there are some TriggerVolumes (as they are called in Unreal Engine 4) inside Babylon. So that i only can use some inputs and interact with meshes when I am inside that volume. I've kinda implemented this in the demo using the distance between the active camera and the hit after scene.pick() method. pickResult = scene.pick(scene.pointerX, scene.pointerY); currentMesh = pickResult.pickedMesh; if (!currentMesh.name.toLowerCase().includes("env") && pickResult.distance < 80) but I am not sure if that is good solution for this project. Thank you all for the help. I hope you have a good day. Quote Link to comment Share on other sites More sharing options...
kcoley Posted October 26, 2018 Share Posted October 26, 2018 Hi @nogalo welcome to the forum! If you want to move the object towards the center of the camera view, you can try calculating a position from the camera position added to a scaled camera forward vector, like this playground: http://playground.babylonjs.com/#BIYF2R#2 You of course would have to take into account distance from walls, etc. As for trigger volumes, @aWeirdo had a good suggestion in this issue if it works for you: nogalo 1 Quote Link to comment Share on other sites More sharing options...
nogalo Posted October 26, 2018 Author Share Posted October 26, 2018 Wow, thank you @kcoley for fast response. This is what I needed. Works perfectly. Have a good one. Cheers kcoley 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.