Page MenuHomeWildfire Games

Unit Pushing
Changes PlannedPublic

Authored by wraitii on May 13 2018, 4:39 PM.

Details

Reviewers
temple
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Owners Package(Owns No Changed Paths)
Trac Tickets
#3442
Summary

(built on top of D13 and some other changes, see https://github.com/wraitii/0ad/tree/D1490_unit_pushing)

This implements (somewhat naively) unit pushing each other when moving, instead of relying entirely on the short-range pathfinder for avoidance.

The short-range pathfinder isn't removed, as it can still be useful inside UnitMotion.

Main benefits:

  • Movement looks more natural in crowds.
  • Less short path requests probably makes this overall faster, though I haven't profiled a lot of cases.
  • Formation units can no longer phase through each other.

Drawbacks:

  • Units are way more huddled together (test out Combat Demo Huge), though that's dependent on pushing settings.
  • Might lead to some bouncing at the moment, needs to be sorted out.

The current implementation is not threaded, and not perfect, as I compare units in their own subdivision and not next to them. This is incorrect, but looks good enough and is faster since my implementation is currently O(N^2) on N=number of units to compare to.

The pushing function itself can be improved.

Test Plan

Test out the feeling, profile things, review code.

Github branch https://github.com/wraitii/0ad/tree/D1490_unit_pushing

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
D13_UM_pushing
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 6053
Build 10085: Vulcan BuildJenkins
Build 10084: arc lint + arc unit

Event Timeline

wraitii created this revision.May 13 2018, 4:39 PM
wraitii edited the summary of this revision. (Show Details)
wraitii edited the test plan for this revision. (Show Details)
Vulcan added a subscriber: Vulcan.May 13 2018, 4:46 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/differential/484/display/redirect

Could you upload a short video of the behavior? So people can have an idea of what's going on without having to download and compile everything themselves.

I'm going to make a forum post about D53, one about this (since in my mind it should get committed alongside D13) with some SVN / patched videos, and some more details. The idea will be to get some playtests as well.

elexis added a subscriber: elexis.May 14 2018, 11:02 AM
elexis added inline comments.
source/simulation2/components/CCmpObstructionManager.cpp
943

I don't want to talk about implementation until the feature design was finished and reviewed, but don't introduce copies.
(The code could be split in a separate commit too in case we weren't focusing on feature design first.)

wraitii planned changes to this revision.May 14 2018, 11:06 AM

Planning changes to clarify that this is probably not that reviewable yet.

source/simulation2/components/CCmpObstructionManager.cpp
943

Oh yeah this is not even used I think, I need to clean this diff a little bit to be honest.

Some footage.
This is SVN: https://www.youtube.com/watch?v=QQC2wrIUHLQ
You can see that the units move around the phalanx formation, the movement around the tree is wonky, and there is a lot of collisions when they return resources.
This is with D13 and D1490: https://www.youtube.com/watch?v=aRfP7lA1m7Y
You can see that the unit can move through the phalanx in a way that looks (imo) somewhat nice, you can see that they clump around the tree much easier, and the ressource shuttling is also easier.
However, you can also see some bugs. Pushing isn't as natural as it could be, and units are oriented all wrong, and there's some jerking, and also formations aren't 100% similar to SVN yet.

Does this patch works only for your own units, or also for the enemy units? Because I think you want to be able to block them, e.g. when you try to defend something.

At the moment it's all units. I've thought about this and I'm not sure how to handle enemy units yet.

I actually personally dislike letting units always block enemies, as I find that a little gamey. My feeling was that this might be good to have at some point, like an "anchoring" feature possibly.

Stan added a subscriber: Stan.EditedMay 15 2018, 6:04 PM

Maybe depending on the stance ? I guess that's for the design document to answer. I'd be in favor of enemies blocking because it makes sense

Imarok added a subscriber: Imarok.May 15 2018, 11:09 PM

What about that: enemy units give some resistance against pushing, but if they get pushed hard enough they also go away. (Not sure if that is easy to implement)

At the moment I'll focus on sane behaviour regardless of ownership, it's fairly easy to add it in later.

My most problematic case will be gathering units, which need to not move too much when pushed or they might no longer be in range.

From what I know about pushing in SC2, stationary units on a task like attacking (or gathering, although that case does not arise in SC2 because gatherers ignore collisions) do not get pushed at all. There are rules about which units can push which other units.

BTW it would be hella cool if elephants could actually shove aside enemy infantry as they charge through, dealing damage. And the same for cavalry charges. Even better if the cavalry slow down the more infantry they hit.

elexis updated the Trac tickets for this revision.Apr 27 2019, 5:33 PM