1
Technical forum / Re: Moving non-actor entities towards an XY position
« on: March 01, 2012, 01:13:27 PM »
I use "for" loops for this rather than if statements. Something like this example:
The i=i+3 and the Sleep(number) can be tweaked to alter the speed.
You could also make a custom method, and then call that whenever you need to.
I realize that you need to move smoothly in both axes... so you will need a slightly more complicated equation in your for loop... but I hope this is helpful.
Code: [Select]
//this moves the object from -75 to 1100 (x coordinate)
for (i = -75; 1<1100; i=i+3)
{
this.X = i;
this.Y = this.Y -1;
Sleep(25);
}
The i=i+3 and the Sleep(number) can be tweaked to alter the speed.
You could also make a custom method, and then call that whenever you need to.
I realize that you need to move smoothly in both axes... so you will need a slightly more complicated equation in your for loop... but I hope this is helpful.