destroyer Posted July 9, 2014 Share Posted July 9, 2014 Hi, I created a ground using: var ground = BABYLON.Mesh.CreateGroundFromHeightMap("", "textures/heightmap.png", 1000, 1000, 250, 0, 10, scene, false); And created my player, which is a Box/Cube: var player = BABYLON.Mesh.CreateBox("Box", 1.0, scene); Now, I want to detect the collision between them. However, when I call this function: ground.getHeightAtCoordinates(player.position.x, player.position.z); I receive this error: Uncaught TypeError: Cannot read property 'boundingBox' of undefined Could somebody help me to solve this issue? Thanks. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 9, 2014 Share Posted July 9, 2014 Hello and welcome! To help you we need to be able to see it live could you use www.babylonjs.com/playground to reproduce your bug? Quote Link to comment Share on other sites More sharing options...
destroyer Posted July 10, 2014 Author Share Posted July 10, 2014 Deltakosh, I separated the minimal necessary to run on your machine, please try the attached.I couldn't run it on the babylonjs playground since I have a heightmap image to load. Thanks in advance.getHeightAtCoordinates.zip Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 10, 2014 Share Posted July 10, 2014 You can use the following example as source:http://www.babylonjs.com/playground/# Thank you:) Quote Link to comment Share on other sites More sharing options...
destroyer Posted July 12, 2014 Author Share Posted July 12, 2014 Delta, I reproduced the bug, please look: http://www.babylonjs.com/playground/#3458P Why can't I retrieve the Height? Thanks! Quote Link to comment Share on other sites More sharing options...
destroyer Posted July 12, 2014 Author Share Posted July 12, 2014 Delta, I solved! I checked the source and I noticed that I had to call: ground.refreshBoundingInfo(); before trying to retrieve the Height. Is this right? Shouldn't it be called automatically at the instanciation? Thanks Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 13, 2014 Share Posted July 13, 2014 You're right. This is because refreshBoundingInfo() is called automatically during rendering process. Here you're trying to retrieve height before, this is why 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.