Jump to content

Implementing forces in Unit Motion (HELP WANTED)


Recommended Posts

@real_tabasco_sauce there is nothing that force elephants or boats to be "solids". Above you have videos of cavalry charging some civilians, you can see it's still doing some physics, but if you don't add "solids" to boats and elephants : 

1. Their collision area is a circle at its center, so things that hit him and that he hit 

  • don't spin him as much as you'll expect
  • have to hit him at center, front and back are ghost parts you can just go through
  • are weaker (elastic)

2. Path-finding don't ignore idle units so they are considered as obstacles

Link to comment
Share on other sites

16 minutes ago, Atrik said:

this thread is already about trying to get units that both try to not overlap

Maybe it would be nice to have some custom scenario with all put in place to test everything (elephants going around tight spaces, them and cavalry charging infantry, ship collisions, etc), while knowing what the idea for each should be. Then we can compare different implementations in many particular situations.

Link to comment
Share on other sites

14 hours ago, Atrik said:

Or maybe trying to reach a waypoint - a intermediate path goal, given by pathfinder -, but since a bunch of elephants are in the way, they wait trying to reach it.

Yes, it could be what you say, and it might be related to a (bad) pathfinding issue. In this latest video of the stationary elephant, I think you can see a clear path that the elephant could take (orange arrow) instead of trying to join the path line that all the others are using. And since it never manages to get into position, it looks like it just stays still.

image.png.44f3e24d7c5d2a70baf45bab8905f724.png

 

14 hours ago, Atrik said:

However I'll disclaim once again that this new "solid" propriety was designed for rare units, to have a very visible superiority when they collide with normal smaller units.
So a large herd of elephants that get this "solid", will always be less agile then other units : they are not made to be in large groups. :sweatdrop:

I understand what you mean and, to some extent, I agree. So far, my intention with these testruns has been to force situations that may not be common in everyday gameplay but are still possible (such as a group of 24 elephants). I'll now start testing more "expected" situations, mixing elephants with infantry. We could also test MP in the next few days. I haven't tried to coordinate because I've been short on time, but we'll find an opportunity. :)

Regarding the forces exerted by the elephant's hitbox, are they the same from the front and the sides, and while turning versus moving straight? For example, in this screenshot from the fourth video (at around 0:30), one elephant fails to reach its waypoint and ends up blocking a huge group behind it. You'd expect the combined force of all those elephants to overcome the resistance of one or two elephants blocking the way.
image.png.edf0a3b52407448b7827e4eb483e3f7a.png

I imagine accumulating forces is complex and could lead to less predictable results. That's why I was wondering whether the side edges of the hitbox could have lower force/resistance, allowing an elephant crossing the path of one coming from the front to be pushed aside. Maybe this is very complex to implement; I'm just throwing the idea out there. Maybe it's simply a matter of improving the pathfinding.

 

Overall, my opinion of this PR is very positive, especially the new infantry and cavalry behavior. I think elephants (or units with the "solid" property) still need some tuning. Since these properties are optional, the PR can be merged as is, but I think fine-tuning them would be valuable to provide good baseline conditions, as we've already seen with infantry/cavalry.

 

Edited by guerringuerrin
  • Thanks 1
Link to comment
Share on other sites

@guerringuerrin I was about to post when I realized you posted :laugh:. Nevermind I'll keep mine as I wrote it initially. And make some reply to yours after.
 

------------------------

12 hours ago, real_tabasco_sauce said:

I think much like for ships, we will have to allow an amount of overlaps for the sake of pathfinding. Otherwise, you might get results that look good on paper but that can end up quite frustrating in practice.

Unless...

 x20 speed, no orders but 2 step rally point.


For nerds, what changed (main changes) :

  • Contact slides, solids slide along each other in the direction they want to go. This fix solids getting stuck on chock-point.
  • Solid are only sensible to soft push if they actually have room to be pushed to. This makes groups of solid expand outward and prevent wiggles because now they only push in one direction. Minimal cost, just coarse grid check.
    Note : Also this idea is a bit of the same than pressure for non-solids. Excepted pressure wouldn't work for solids because their shape is different, and the pushing is different too, so its barely more costly, but works very well for solids.
  • Improved contact logic so also actually even less overlapping on choke-points. ^_^


Ok but now, the question is... Will @guerringuerrin  manage to get some elephants stuck this time? :D

  • Haha 1
Link to comment
Share on other sites

14 minutes ago, guerringuerrin said:

image.png.44f3e24d7c5d2a70baf45bab8905f724.png

Can't tell in from the picture, but it's also very possible that the elephant here was stuck at this angle due to the ones pushing on it's butt... But this should happen less often, and elephants should be able to unstuck themselves sooner now.

You can also enable "UnitMotion" in dev overlay to display the path, this can help figuring if it's actually a pathfinder weirdness or a bug.

  • Like 1
Link to comment
Share on other sites

18 minutes ago, guerringuerrin said:

Regarding the forces exerted by the elephant's hitbox, are they the same from the front and the sides, and while turning versus moving straight? For example, in this screenshot from the fourth video (at around 0:30), one elephant fails to reach its waypoint and ends up blocking a huge group behind it.

Yes they are. Well for the most part. There is also soft push gradient (not really the hitbox, but like a softer wider hitbox) and also some logic that tries to push if two bodies already overlap.

Link to comment
Share on other sites

23 hours ago, Atrik said:

Is your tests using the updated code

I'm using the latest b53b24adc2 now. I think an issue now is that they are really stubborn to turn :P, and that can block paths or cause them to be dragged sideways somewhat easily (see the 1v1 after 0:15):

I guess some turning would be more realistic than being pushed sideways like that, imagining it's on their own accord, which makes me think if there shouldn't be a difference between how enemy and own units react.

 

 

  • Like 2
Link to comment
Share on other sites

35 minutes ago, Thalatta said:

I think an issue now is that they are really stubborn to turn :P

Well here you are trying hard to make the geometry show it's limits :sweatdrop:

In the first example, a rectangle pushing another one against the wall is kinda expected to do this slide.
963934106_Screenshotfrom2026-10-0117-26-31.png.4e5181b105a0062da6cfa20823581d97.png

In the second example on open terrain, I see you manually try to aim for the elephant's center, despite it trying to rotate!! :o

But you can actually try to tweak values even without recompiling :
in `pathfinder.xml` you have the parameter `
SolidPushSpin`, which makes the circle pushing/soft pushing impact more or less units spins. Currently it's low (0.25), if you increase it, your elephants will spin faster in that case, but this also means elephants moving shoulder to shoulder might also wiggle a bit more.

 

Edited by Atrik
  • Like 1
Link to comment
Share on other sites

45 minutes ago, Thalatta said:

I'm using the latest b53b24adc2 now. I think an issue now is that they are really stubborn to turn :P, and that can block paths or cause them to be dragged sideways somewhat easily (see the 1v1 after 0:15):

I guess some turning would be more realistic than being pushed sideways like that, imagining it's on their own accord, which makes me think if there shouldn't be a difference between how enemy and own units react.

I like this behavior much more than what could be seen in my videos from the previous commit.

I'm not sure to what extent it will be possible (or desirable) to make the behavior more realistic, but getting them to rotate a little when they are pushed would be really good, as it would make the behavior more realistic and, in many cases, could help open up paths for them to move through more quickly. 
But, in fact, I think this result is quite acceptable.

And what I like most about this new patch is that the elephants entering the narrow path looks much smoother and more natural. They’re still clumsy and slow, which is fitting for something so large and heavy. But the movement flows much better than in the previous version, which felt stiff and a bit “dumb” ;)
image.png.5a32624f12f6adc576124c560f09db33.png

Edited by guerringuerrin
Adding some more thoughts and an image.
  • Thanks 1
Link to comment
Share on other sites

10 minutes ago, guerringuerrin said:

but getting them to rotate a little when they are pushed would be really good, as it would make the behavior more realistic [...]

They do! @Thalatta is just master trickster here! :sweatdrop:

Joking, but maybe we can increase the SolidPushSpin as explained above. I had this parameter added before doing the "push only if we have room to push", so maybe a higher value now will still results in still acceptable level of wiggles.

Edited by Atrik
  • Haha 1
Link to comment
Share on other sites

2 minutes ago, Atrik said:

They do! @Thalatta is just master trickster here! :sweatdrop:

That’s why it’s good to have more people doing the testing. There are a thousand ways to break your work haha:rofl:. Just kidding, it’s great that @Thalatta managed to compile it and test it. :)

Alright, I’ll do some testing of my own tonight with this. Great work!

  • Like 1
Link to comment
Share on other sites

14 hours ago, Atrik said:

Well apparently this thread is already about trying to get units that both try to not overlap, and still manage to move around in groups of 50 without too much weird stuff happening... :laugh:

I am aware that these are mutually exclusive to a degree.

I am just saying elephants and ships are already very clumsy as is. On the ship side, there have been discussions to scale down ships for a while which would help.

For elephants, we have the upside of improved pathing through own and enemy units, which is sick, but problems are clear when handling forests and buildings.

13 hours ago, Atrik said:

1. Their collision area is a circle at its center, so things that hit him and that he hit 

  • don't spin him as much as you'll expect
  • have to hit him at center, front and back are ghost parts you can just go through
  • are weaker (elastic)

Unless I am mistaken, it seems like these 3 points are less "mission critical" to the elephant attack and charge effects.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...