rgalindox Posted December 11, 2018 Share Posted December 11, 2018 Hi, I'm trying to create a ray from one mesh to another one, but I have problems with the direction. I'm using this one: var ray = new BABYLON.Ray(); var rayHelper = new BABYLON.RayHelper(ray); var localMeshDirection = new BABYLON.Vector3(-1, 0,0); var localMeshOrigin = new BABYLON.Vector3(0, 0, 0); var length = 20; var door = scene.getMeshByName("shop08"); rayHelper.attachToMesh(door, localMeshDirection, localMeshOrigin, length); rayHelper.show(scene); In the above case I have a ray on the -x axis, but I need to use the direction of a specific mesh, basically when the user click on any mesh the ray will check for collisions in between. How can I get the direction of a specific mesh and include it on the rayHelper.attachToMesh ? Thanks for your valuable help. Rafael Quote Link to comment Share on other sites More sharing options...
rgalindox Posted December 11, 2018 Author Share Posted December 11, 2018 Hi, I figured out : now I need to see the collision function myRay(){ var door = scene.getMeshByName("mesh1"); var punti= scene.getMeshByName("mesh2"); var origin = door.position; var forward = punti.position; var direction = forward.subtract(origin); direction = BABYLON.Vector3.Normalize(direction); var length = 20; var ray = new BABYLON.Ray(origin, direction, length); let rayHelper = new BABYLON.RayHelper(ray); rayHelper.show(scene); } GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted December 11, 2018 Share Posted December 11, 2018 Perfect. Feel free to use our new forum for now as well Forum.babylonjs.com Quote Link to comment Share on other sites More sharing options...
rgalindox Posted December 12, 2018 Author Share Posted December 12, 2018 I'll do thanks! 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.