D
Dawn
Guest
I wrote a script for alarm events that an object changes coordinates over time to the destination.
I set the length, the direction and the duration (steps) and the alarm will move the object's coordinates by [length/duration] for [duration] steps. The code below is not an actual code and excludes the repeating part.
The sum of (length/duration)*duration and the length should match... and they don't.
So, I set additional variables for storing coordinates then copied the values to coordinates then it fixed the problem.
I got a feeling that this is actually intended for maybe the optimization issue, but I'm not sure. Honestly I think this is pretty dumb.
I set the length, the direction and the duration (steps) and the alarm will move the object's coordinates by [length/duration] for [duration] steps. The code below is not an actual code and excludes the repeating part.
Code:
//STEP
var len=total_length/n;
var len_x=lengthdir_x(len,dir);
var len_y=lengthdir_y(len,dir);
x+=len_x;
y+=len_y
//run this n times
So, I set additional variables for storing coordinates then copied the values to coordinates then it fixed the problem.
Code:
//STEP
var len=total_length/n;
var len_x=lengthdir_x(len,dir);
var len_y=lengthdir_y(len,dir);
ACTUAL_X+=len_x;
ACTUAL_Y+=len_y;
x=ACTUAL_X;
y=ACTUAL_Y;
//run this n times