Jump to content

Implementing forces in Unit Motion (HELP WANTED)


Recommended Posts

1 hour ago, nifa said:

The ship's movement looks really natural.

My favorite too :laugh: Hopefully it can be a good starting point to make naval battles very different then land battles.

1 hour ago, nifa said:

(on the elephant attack too late, on the catapult impact too early?). I think it's nice and I wanna encourage anyone who is able to test it :)

Right.

 

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

11 hours ago, Atrik said:

Already ships not going through each other is an astronomical improvement (although realistically, for the more direct impacts the ram would perforate the other ship and reversing would be needed to separate them). I hope the same could be implemented for land units, making their movements more natural and their tactics more relevant.

Link to comment
Share on other sites

4 hours ago, Thalatta said:

although realistically, for the more direct impacts the ram would perforate the other ship and reversing would be needed to separate them). I hope the same could be implemented for land units, making their movements more natural and their tactics more relevant.

You are such a gigantic troll :laugh:
But I'll bump on it still, and give some nerdy details.

The collisions between units are not indeed like solid bodies that are impossible to overlap, even with this PR, this will remain true for most units. It's more a spring-like push that tries to make units keep distance to each others. This pushing just use a distance-to-center repulsion force.

What's introduced here for boats and elephants is a different stronger pushing and that actually take the unit's shape into account. This is why on the video you see that the hulls act like actual solid bodies. However simulating this, is ~x1.5 time costlier then the simple radial spring pushing. So because that, for small units, the difference in visible behavior would be minor, better go with the simple pushing, and use the better one only for big units that get the most benefits from it.

A fun fact is that before this PR, all units were treated the same, so you did had still this radial-pushing for boats (the collisions were spring-like and only a small circle at the center of the boat was even acting as the hitbox) but it was still much bigger then for, say infantry.
To detect if units were colliding, the map had a grid that allowed each unit to search a limited area where it might be actually colliding with other units. This grid size had to be proportional to the largest pushing unit of the game : boats - who's pushing effects where questionable anyway.
Even if you played on mainland map with no ships whatsoever, the grid was sized to work for boats too. And your unit had to check their distance with much more other units they needed to.
So you can say that the lag you experience on mainland, was partially due to ships.



This along a few other optimizations with the pushing and more resilient obstruction handling, make the PR a performance improvement for common scenarios (yey!).

Link to comment
Share on other sites

49 minutes ago, Atrik said:

You are such a gigantic troll :laugh:

Hardly :P, just pointing out history, realism, and possible improvements, more so considering many have stated a preference for tactics and formations becoming more relevant, which units not going through each other would automatically provide, in good part :)

 

49 minutes ago, Atrik said:

The collisions between units are not indeed like solid bodies that are impossible to overlap, even with this PR, this will remain true for most units. It's more a spring-like push that tries to make units keep distance to each others. This pushing just use a distance-to-center repulsion force.

What's introduced here for boats and elephants is a different stronger pushing and that actually take the unit's shape into account. This is why on the video you see that the hulls act like actual solid bodies. However simulating this, is ~x1.5 time costlier then the simple radial spring pushing. So because that, for small units, the difference in visible behavior would be minor, better go with the simple pushing, and use the better one only for big units that get the most benefits from it.

Sure, but it's a theory/practise issue. Shouldn't increasing the radial repulsion force at a given distance (in physical terms, the elastic constant k, or stiffness) of land units achieve a more "solid" effect? Would this be costlier to simulate? I wonder how your cavalry turning would look in that case, for example.

Link to comment
Share on other sites

1 hour ago, Thalatta said:

Shouldn't increasing the radial repulsion force at a given distance (in physical terms, the elastic constant k, or stiffness) of land units achieve a more "solid" effect?

You can see how "solid effect" of "stiffness" impact the boats in the video. You get super cool effects when there are a few ones, but a lot of them result in them taking a lot of time to settle. It's fine for boats as you rarely think of crowds of boats, and I just made a scene for this in the video to show that it works, and still look good for them.
But if you have a crowd of infantry constantly wiggling and taking forever to settle, this would look very bad. Hence the spring.

 

1 hour ago, Thalatta said:

I wonder how your cavalry turning would look in that case, for example.

Inertia and pushing aren't the same thing. But for navigating on open terrain, this wouldn't change much. However if you try to funnel "solid" physical bodies into a choke-point, they obviously take a while more to achieve the same movement.
So if ever we wanted to make cavalry "solid bodies", with this PR it's only just one tweak in their template. But because big crowds of them cost more to simulate and that moving them around take longer if they are in high number, it should be accompanied by an increase of cost/population for example. The pros are that they will have much more realistic charge effects, like you see with elephants, but cavalry have less contact area and are moving much faster, the physic outcome would be different too (like a cavalry can trow fewer infantry units away but at higher velocity). So this is just a balancing change, out of scope.

Even without proper "charge", -so just using the old pushing  pretty much as it was, the inertia improves physics for cavalry fighting at no additional cost. The cavalry can push away other spread units thanks to it's superior weight, and also push its target by a little - even if ideally it would be more, and the cavalry would be smart enough to take more advantage of it instead of stopping once in front of it's target.

 

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

24 minutes ago, Atrik said:

Inertia and pushing aren't the same thing. But for navigating on open terrain, this wouldn't change much.

Of course they aren't the same thing, those would somewhat correspond to independent Newton's laws after all. I was referring to the effects of their combination. What I noticed is that when cavalry change direction they go a bit into each other, and I wondered how their movement would change without doing so. But you say both "it wouldn't much" and "cost more to simulate", along with representing a "balancing change", the latter I think should be considered since far too many sword infantry seemed to be having a go at that poor elephant (avoidance and ranged attacks, mainly javelins if I remember correctly, is how the Romans dealt with them), although of course that's another discussion, but good if "with this PR it's only just one tweak".

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...