giorfasolini Posted May 5, 2017 Share Posted May 5, 2017 Greetings Forum, I hope you have a great day Today, I would like to ask how to randomize position in babylon.js. I have one Apple object which i would like to randomize its position everytime i touch it. Here's a screenshot of what my game looks like. As can be seen, I am trying to randomize the apple position to make it more like point collecting game. I'm trying to follow tutorial here But the program crashed, and wont work ... Any Attention or solutions will be greatly appreciated, cheers P.S : I tried to upload it to playground, but it seems not working because my apple and sonic are on different files, hence i can only provide a screenshot to help the forum to understand my question , I'm sorry for my lack of knowledge // Creation of Apple for(var i=0; i<20; i++) { x = randomNumber(-100, 100); z = randomNumber(-100, 100); var apple2; BABYLON.SceneLoader.ImportMesh("","Finalproject/", "apple.obj", scene, function (newMeshes, particleSystems, skeletons) { apple2 = newMeshes[0]; apple2.position.x = x; apple2.position.z = z; }); } Quote Link to comment Share on other sites More sharing options...
giorfasolini Posted May 5, 2017 Author Share Posted May 5, 2017 I have managed to solve this issue, using Math.floor and Math.random My humblest apologies to the community , cheers GameMonetize 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.