Jump to content

Move mesh to a new position


maronvert
 Share

Recommended Posts

Hello everybody

I have a mesh that starts on a certain position.

 

Now every 5 seconds I want it to move to another x-position.

All the positions the mesh should go are stored in an array.

How can I make the mesh move to a random position that's specified in the array?

 

var array=[10, 20, 15,  30, 45,]

 

So for example it starts at

 

mesh.position.x = 10

 

next (after 5 seconds) it should go to

 

mesh.position.x = 30

 

then

 

mesh.position.x = 15

 

and so on. just randomly.

I already know how to write the code for the 5 seconds but how can I make it change randomly?

 

Thanks

 

Link to comment
Share on other sites

  • 2 weeks later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...