zoot Posted July 26, 2012 Report Share Posted July 26, 2012 See from 1:17 in this video: When groups of units walking in formation is catching up to some path that has been traced for them, they move in a jerky, "turn-on-a-dime" kind of way (it's particular gross at around 1:26). What is the reason for this? Are there any options for smoothing out this motion? Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted July 26, 2012 Report Share Posted July 26, 2012 I believe it's the Formation component adjusting all units simultaneously to stay oriented with the (invisible) formation entity. The reason is there's no better logic implemented yet Quote Link to comment Share on other sites More sharing options...
zoot Posted July 27, 2012 Author Report Share Posted July 27, 2012 I'll have to try and track down that piece of code and see what can be done. Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted July 27, 2012 Report Share Posted July 27, 2012 If you do, one thing we definitely want is a "snaking" behavior for the column / long distance formation. I guess other formations should have some kind of smooth "wheeling" behavior around a given point (obstacles will still cause issues, but in the open it should be smooth). Also it's worth considering the difference between how infantry can move vs. cavalry and siege units. Quote Link to comment Share on other sites More sharing options...
zoot Posted July 27, 2012 Author Report Share Posted July 27, 2012 Note to self (and anyone else who might be interested): source/simulation2/components/CCmpUnitMotion.cpp is probably the relevant source file. Quote Link to comment Share on other sites More sharing options...
zoot Posted August 1, 2012 Author Report Share Posted August 1, 2012 (edited) I think this is the relevant piece of code:// Face towards the targetif (!offset.IsZero()){entity_angle_t angle = atan2_approx(offset.X, offset.Y);cmpPosition->TurnTo(angle);}In context, I interpret "target" as meaning "next waypoint on the path". If so, the call to cmpPosition->TurnTo(angle) would be what gives the abrupt, turn-on-a-dime behavior.Probably what happens is that the pathfinder traces a completely linear path for the unit and the UnitMotion component follows it slavishly, so jerkiness arises around the 'joints' of this path.If this is the case, I think fixing this would actually require changes to the pathfinder to have it create smoother (non-linear) paths. We can probably not just interpolate a curved path from the linear path, because an interpolated path might collide with obstructions that only the pathfinder can account for. Edited August 2, 2012 by zoot Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted August 2, 2012 Report Share Posted August 2, 2012 If this is the case, I think fixing this would actually require changes to the pathfinder to have it create smoother (non-linear) paths. We can probably not just interpolate a curved path from the linear path, because an interpolated path might collide with obstructions that only the pathfinder can account for.I think a different pathfinding mode could help there, but it has to be considered that there are a number of different formations and the desired motion is formation specific (down to the individual unit and type of unit). I'm not sure how well that generalizes. Can it be accomplished with the existing pathfinder, with the unit motion planned by the formation logic? Maybe the formation can generate a series of points for each unit to follow independent of obstacles and which handles changes of direction more nicely, then pass them to the pathfinder for obstacle avoidance.Here's another problematic case I've noticed. When one unit is in pursuit of another, it has to stop constantly when it reaches its destination, which means fast units pursuing slow units look silly and are mostly ineffective. Instead the pursuit should be continuous, especially in combat, a cavalry unit should pursue and then pass "through" its enemy, without stopping and possibly with a speed burst. Not only in combat but with escort or guard behaviors. So a "follow" or "pursue" pathfinding mode would also be helpful IMO. Quote Link to comment Share on other sites More sharing options...
zoot Posted August 2, 2012 Author Report Share Posted August 2, 2012 (edited) I think a different pathfinding mode could help there, but it has to be considered that there are a number of different formations and the desired motion is formation specific (down to the individual unit and type of unit). I'm not sure how well that generalizes. Can it be accomplished with the existing pathfinder, with the unit motion planned by the formation logic? Maybe the formation can generate a series of points for each unit to follow independent of obstacles and which handles changes of direction more nicely, then pass them to the pathfinder for obstacle avoidance.I can't immediately imagine how that would work. Maybe a brute-force way could be to interpolate a smooth path and just let the chips fall where they may. As far as I understand, units will have their paths recomputed if they hit anything on their way - but I don't know how well it all would look.Here's another problematic case I've noticed. When one unit is in pursuit of another, it has to stop constantly when it reaches its destination, which means fast units pursuing slow units look silly and are mostly ineffective. Instead the pursuit should be continuous, especially in combat, a cavalry unit should pursue and then pass "through" its enemy, without stopping and possibly with a speed burst. Not only in combat but with escort or guard behaviors. So a "follow" or "pursue" pathfinding mode would also be helpful IMO. From what limited understanding I have, it should be fairly easy to simply cap the speed of the fastest unit to the speed of the slowest unit once the former has reached the latter. If for any reason the slow unit drifts out of range again, the fast unit would reset its speed to max until reaching the slow unit again. Edited August 2, 2012 by zoot Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.