willemmulder Posted January 18, 2016 Share Posted January 18, 2016 For a game, I need many AI units to calculate whether they 'see' each other or not. After some googling, I think I might have to go with raycasting and do something like this: http://www.redblobgames.com/articles/visibility/ (great demo BTW!) or even simply cast a ray from every unit to every other unit and check if there's nothing in-between..? Has somebody already done something similar for babylonjs? Or should I work with a light, let Babylonjs calculate it's shadowmap or something like that? Quote Link to comment Share on other sites More sharing options...
Temechon Posted January 18, 2016 Share Posted January 18, 2016 It would be easier to work with raycast. It's very easy to do it wih Babylon (of course ) Just create a Ray: http://doc.babylonjs.com/classes/2.2/Ray and use the method scene.pickWithRay : http://doc.babylonjs.com/classes/2.2/Scene#pickwithray-ray-predicate-fastcheck-rarr-pickinginfo-classes-2-2-pickinginfo- You can find some examples here: http://doc.babylonjs.com/playground?q=pickwithray Quote Link to comment Share on other sites More sharing options...
willemmulder Posted January 18, 2016 Author Share Posted January 18, 2016 Thanks, that worked! One small additional question: is there an option to do raycasting and get every colliding object on that ray, so not just only the closest one? Quote Link to comment Share on other sites More sharing options...
Temechon Posted January 18, 2016 Share Posted January 18, 2016 I dont think it exists as is... A simple way to do this would be to cast the ray each time an object is found, while an obstacle is found. 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.