Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Moving an object set distance

Author
Message
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 19th Jun 2006 21:15
I want to move an object a set distance. So far I can move one but it never stops! What is the code to do this? I want the object to move automatically, not when a key is pressed.
I have seen this question in the archives but the answer didnt explain it properly.
So far I have my loop:
Do
Move object 1,1
sync
Loop
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 19th Jun 2006 23:39 Edited at: 19th Jun 2006 23:40
so you want it to move forward and then stop when it has moved a certain distance forward? Well, to put it simply...

if your object is rotated at an angle of 0 on all axis (This is the default setting) and if it is positioned at 0 on the z axis, you could just say...

Do
If Object Position Z(1)<(Distance Away) then Move object 1,1
sync
Loop

And it would stop moving after it got there.

Change the Distance Away to a number.


That's one possible thing. IF you rotate the object, however, things could change. I'm not exactly sure what the easiest code for this would be off of the top of my head, but it would probably involve the newzvalue() and possibly the newxvalue() commands...

Oh well, that's all I have to say.

I doubt you can draw me/60 by hand, so you REALLY can't draw ME/1, can you?
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 19th Jun 2006 23:41
You could put it in a for...next loop


or you could use an if test



or you could use a while loop



Do...Loop is usually used for when you want something to keep happening for a very long time in a program. It is usually used for the main loop of the program.

Insanity is just a state of mind
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 20th Jun 2006 20:01
Thanks For your help!!

Login to post a reply

Server time is: 2024-11-26 17:29:36
Your offset time is: 2024-11-26 17:29:36