Okay.. So I was playing around with the mouse movement event. I used the event to update mouse cursor position, and I used a separate trigger (Attached below) to move a unit according to preset velocity/acceleration gradients. Here's the problem.. Whenever I hover my cursor too far to the left or right of the screen and allow the trigger below to do it's work, it's thread just magically terminates for no reason (after the unit arrives at the map border).. No error message, nothing :( You may notice a debug message at the bottom that says "Terminate". Even that doesn't display... Thus the whole thing is breaking without the while loop condition failing.
This has got me baffled and will probably keep me up tonight.. If anyone could provide some help on the matter as to how I can stop the thread terminating prematurely, I would appreciate it. I've gone through this code lot's of times but I don't see any reason why it should be failing... I've attached the map as a reference.. The trigger is located under Movement > t_Movement
PS: I got confirmation that the thread terminates with the trigger debugger window. And also please note.. If running in window mode, the attached map will lag because of the influx of events...
No particular reason, except that I overlooked the ATan2 function.
What's the difference though?
I'm guessing it is able to detect divide by zero and spit out Inf, since ATan2 calculates dy/dx within it, Whereas with ATan, dy/dx is calculated, then passed as a parameter to the ATan function
Okay.. So I was playing around with the mouse movement event. I used the event to update mouse cursor position, and I used a separate trigger (Attached below) to move a unit according to preset velocity/acceleration gradients. Here's the problem.. Whenever I hover my cursor too far to the left or right of the screen and allow the trigger below to do it's work, it's thread just magically terminates for no reason (after the unit arrives at the map border).. No error message, nothing :( You may notice a debug message at the bottom that says "Terminate". Even that doesn't display... Thus the whole thing is breaking without the while loop condition failing.
This has got me baffled and will probably keep me up tonight.. If anyone could provide some help on the matter as to how I can stop the thread terminating prematurely, I would appreciate it. I've gone through this code lot's of times but I don't see any reason why it should be failing... I've attached the map as a reference.. The trigger is located under Movement > t_Movement
PS: I got confirmation that the thread terminates with the trigger debugger window. And also please note.. If running in window mode, the attached map will lag because of the influx of events...
Additional Info:
Urgh.. Found the culprit.
a = ATan(dy/dx);
Divide by 0 =_=
I shall go bang my head on the wall now...
This thread is the definition of irony.
The thought of this actually made me burst out in laughter :D
Is there a reason you used Atan(dy/dx) instead of Atan2(dy, dx)?
@Deaod: Go
No particular reason, except that I overlooked the ATan2 function.
What's the difference though?
I'm guessing it is able to detect divide by zero and spit out Inf, since ATan2 calculates dy/dx within it, Whereas with ATan, dy/dx is calculated, then passed as a parameter to the ATan function
@FuzzYD: Go
It also does the quadrant correction automatically, afaik.
€ http://en.wikipedia.org/wiki/Atan2
@Kueken531: Go
If it settles quadrant correction, it sounds like an awesome function. I'll certainly start using it.