User mini profile

- Sun 3 Dec 2017, 23:26#64257
I have a set of events that move a Unit Sprite after left-clicking on it, then selecting a point on the screen.It goes to the designated point without issue, but when it gets to the position/objet, it starts shaking. I've tried applying Stop events to the movement force, but to no avail (see attachment).

unit-movement-stop.png (97.02 KiB) Viewed 1126 times

What am I missing?

(P.S. If anyone has any suggestions on streamlining those events at the same time, I'd love to hear them! Always looking for ways to improve my events )

User mini profile

- Sun 3 Dec 2017, 23:30#64258
Also, whilst people are looking at this section of events, the mapRallyPoint sprite image isn't showing up when I place it with the right-click. I haven't placed it in the game itself, as I only need it when a unit is moving and don't want it to be visible when it's not being used. Is that's what's causing it?

User mini profile

- Tue 5 Dec 2017, 00:25#64264
What is the value of unitMoveSpeed? If it is too large then your distance conditions in the subevents of event 3 may never be triggered because it never gets closer than 10 pixels as it keeps overshooting and then having to go back the other way. That would explain a shaking effect. Temporarily either decrease the movement force to 10, or increase the distance to be 100 pixels and see if either of those fix it.

User mini profile

- Tue 5 Dec 2017, 01:50#64266
MattLB's suggestion should do the trick. If anyone is wondering if it can be done in a more reliable way, no matter your FPS or movement speed, you can do a simple analytic test. TimeDelta() returns the time elapsed since the last frame, your object is moving at "Speed" pixels/second, and your destiny is at "Distance" pixels of distance, then if:

Your object will reach the destiny this frame, so you can put it right on the destiny an start the destiny-reached-logic. This is because Speed * TimeDelta() returns the distance your object can advanced in TimeDelta() seconds. This is other type of logic, instead moving the object this entire distance and then check if it is close to the destiny (you have problems here at low FPS or high speeds), check if the distance it can advance is less than the distance it needs to advance

I haven't tested it, pure theory, but I guess it works better if you put this check before the event your start moving, to avoid it: Set destiny, moving very fast, automatically reach the destiny in the same frame instead waiting the next frame.

User mini profile

MattLB wrote:What is the value of unitMoveSpeed? If it is too large then your distance conditions in the subevents of event 3 may never be triggered because it never gets closer than 10 pixels as it keeps overshooting and then having to go back the other way. That would explain a shaking effect. Temporarily either decrease the movement force to 10, or increase the distance to be 100 pixels and see if either of those fix it.

It occurred to me that I forgot to update this thread.You managed to nail the problem. I'd set a movement speed of 100 for quicker testing, and so was nowhere near the 10 pixel condition. Changing the movement speed to 10 pixels fixed it! I've changed it back to 100 to continue with testing, but have made a note to change it when releasing/beta testing it.