Page MenuHomeWildfire Games

[very WIP] Unit Pushing
Needs ReviewPublic

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

On Github: https://github.com/wraitii/0ad/tree/motionmanager

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

Design goals:

  • Movement looks more natural in crowds.
  • Fewer short path requests making the game faster in general (despite pushing taking some time to compute - I think it's an easy win overall).
  • Less reliance on the short-pathfinder reducing the # of issues with it.
  • Ideally be thread-able.

Conceptual drawbacks:

  • Fundamentally might make it harder to avoid units "phasing" through each other.
  • Fundamentally introduces more movement in units, which might look odd sometimes.
  • Still needs the short range pathfinder to exist to get around some types of obstacle.

Open design questions:

  • How much to push?
  • Should some units be unpushable? Should enemy units be un-pushable?

Open implementation questions:

  • How to know when we can't "push through" and need to trigger an "obstructed" call. It looks weird when ordering many units to clump together.

Implementation-wise, this has two main components:

  • A unitMotionManager that splits unit Motion in phases, so that we can have a "middle" phase where units don't send messages and can be used for pushing safely and quickly.
  • Actually pushing stuff.

My current implementation is braindead, and basically compares all units with all other units (once), essentially a n^2 algorithm. It remains pretty fast however. I think some subdivision will be necessary to avoid the n^2 exploding too much, but since the short-pathfinder is n^3+ we have a fairly good margin to work with.

Test Plan

At the moment, I'm mostly looking for comments on how the pushing looks.

Test this out here: https://github.com/wraitii/0ad/tree/motionmanager

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
946

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
946

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
wraitii updated this revision to Diff 13116.Aug 6 2020, 6:52 PM
wraitii retitled this revision from Unit Pushing to [very WIP] Unit Pushing.
wraitii edited the summary of this revision. (Show Details)
wraitii edited the test plan for this revision. (Show Details)

Extreme rebase (aka complete rewrite but the idea is there).

This is very trivial implementation, though it essentially shows what to expect: units are pushed.

It incorporates the "unit motion manager", which is most of the changes for now. I think ultimately I'll merge that separately, but it doesn't make too much sense to do it unless I also merge pushing after, so until I'm sure I've got good-enough pushing I won't separate the diffs to make it easier to test.

Vulcan added a comment.Aug 6 2020, 7:20 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2930/display/redirect

wraitii updated this revision to Diff 13136.Aug 7 2020, 3:59 PM

Actually do something... Managed to break it yesterday.

This also re-enables formations, so it's testable.

Vulcan added a comment.Aug 7 2020, 4:26 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2945/display/redirect

A little testing:

  • Garrisoning is broken.
  • Entities can be pushed off the map.
  • Entities often stop in their tracks.
  • At some point there were three entities that wanted to be close sooo badly that they kept standing/moving on exactly the same spot xD
  • You can be pushed by your enemy,,,
myou5e added a subscriber: myou5e.Aug 20 2020, 3:38 PM

A little testing:

  • Garrisoning is broken.
  • Entities can be pushed off the map.
  • Entities often stop in their tracks.
  • At some point there were three entities that wanted to be close sooo badly that they kept standing/moving on exactly the same spot xD
  • You can be pushed by your enemy,,,

Pushed by your enemy sounds like a good thing :-)

wraitii updated this revision to Diff 15789.Mon, Feb 1, 3:49 PM

Rebase & implemented on top of D3509.
Still the same braindead implementation for now. Identified needs are adding clearance & probably optimisations.
This also fixes the chasing asymetry so I can probably remove that code now.

Vulcan added a comment.Mon, Feb 1, 3:50 PM

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

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/4792/display/redirect

Vulcan added a comment.Mon, Feb 1, 3:52 PM

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

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/3134/display/redirect