Sign in to follow this  

How to randomize Object position? SOLVED

Recommended Posts

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;



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.