Hey, first I'd like to say I appreciate the great physics library you have created here. Second, I'm having a bit of an issue with my click-to-move system. Essentially I want it to behave like a Diablo style system but I've run into a bit of an issue. It seems like whenever I click to move the EntityMover hangs for a fraction of a second. This becomes a huge issue when holding down the mouse button to rotate and what not as well (it moves really really slow since it is recalculating and hanging a bunch). I'm new to the library so I'm not 100% sure exactly how to fix this. Here are the relevant code bits:
By hang, do you mean it takes a long time to compute? I don't see anything in there that would explain excess computation time. I would recommend checking a profiler to get a rough idea of where the time is being spent. If the time is spent actually in this code, check for weird conditions like NaNs or billions of unnecessary invocations.
Also, note that the entity mover and paths stuff isn't fundamental to the engine, and it's often simpler to not use it (unless you really want a cardinal spline or something like that).
Hey Norbo, thanks for the response. What I mean by hanging is it pauses for a fraction of a second (main thread doesn't freeze) when it switches to a new path. The entity just sorta chills there and doesn't move at all. The actual calculation time doesn't seem to be effecting it significantly, which is strange. What I tried doing to verify this is creating the path on another thread and blocking new threads from being created while this computation was happening. During the next main thread update it would pick up the newly generated path and begin traversing it. Unfortunately I ran into the same problem once again, the entity pauses briefly before starting the new path.
At a glance, I don't notice anything in the posted code which would explain that. The EntityMover is very simple- for dynamic entities it wraps a motor, and for kinematic entities it just sets velocities directly. As long as the EntityMover goal is being set and everything is in the space that should be, there's no physics-side reason for a pause.