ZeroK-RTS / Zero-K

Open source RTS game running on the Spring/Recoil engine
https://zero-k.info
GNU General Public License v2.0
683 stars 204 forks source link

Gravity beams: ground friction exceedingly high #2359

Closed DeinFreund closed 3 years ago

DeinFreund commented 7 years ago

They don't seem to obey Newton's laws at all. It's easy to lift up units, but pulling them across straight terrain is impossible.

In http://zero-k.info/Battles/Detail/461645 a Sumo fires both rays at a Firewalker and doesn't move him a bit. (Screenshots to follow)

DeinFreund commented 7 years ago

sumo

As you can see the sumo had a clear shot but the Firewalker was completely unaffected.

It seems like there is some kind of really strong friction with the ground. Whenever the force vector lies close to flat on the ground, units are near impossible to move, yet they can be flung about when pulling them from above.

sprunk commented 7 years ago

I think this has always been the case.

DeinFreund commented 7 years ago

The coefficient of friction being above unity is rather unintuitive. Would it be possible to change that so that all units that can be lifted up can also be pushed/pulled?

sprunk commented 7 years ago

Possible but not easy. You'd need to detach a unit from the ground to overcome friction which has to be done only if the unit would actually be pushable (else newton stops det), but it might be hard to know whether that is the case because engine physics is a black box.

DeinFreund commented 7 years ago

You'd need to detach a unit from the ground to overcome friction

This sounds so (physically) wrong. Without a ground connection there is no more friction, so even heavy units would be helpless as soon as affected by a gravity beam. There should be a force of friction which depends on the ground composition and the unit's mass. This allows the unit to move at will while there's also a force applied by the gravity beam. As soon as the gravity beam's force overcomes the force of friction, the unit starts sliding with the difference of the forces. At the same time it can still move at its normal speed, just while also sliding. Then we can finally moonwalk on MoonQ20x.

Without some way of approximating this, Sumo just feels like a way too random unit. How can we explain it pushing striders twice its weight off the map while at the same time failing to dislodge lightweight support units.

sprunk commented 7 years ago

Currently either you're attached to the ground and are unaffected by grav, or are detached at which point can't move on your own at all.

Changing this to make movement the sum of forces sounds like a nightmare though. What about pathing, weapon leading prediction?

DeinFreund commented 7 years ago

Pathing tells the unit where it wants to go, it's up to the unit to apply its method of movement to follow this path. Prediction can also be done by AI and widgets that completely ignore pathfinder, looking at derivatives of position is all that is needed. A physics engine shouldn't move units via anything other than newton's law (=forces) imo.

Anyway this isn't how Spring works, so I suppose some kind of workaround via Lua is needed. In the worst case just do it as you proposed and lift up units as soon as their weight times coefficient of friction is smaller than the gravity beam's strength. I guess one could also try implementing the entire gravity beam in Lua via movectrl, but this would be pure engine abuse.

sprunk commented 7 years ago

it's up to the unit to apply its method of movement to follow this path

Yes but currently units assume they can only be moving in the direction of their heading (not sideways or at an angle). It would need a complicated engine patch. Ultimately Spring is not a physics engine, it's an RTS engine and the physics are mostly gimmicks.

just do it as you proposed and lift up units as soon as their weight times coefficient of friction is smaller than the gravity beam's strength

Yes but that is not trivial either. You'd need to reimplement impulse handling in Lua.

DeinFreund commented 7 years ago

We could also reposition the beams to be on the top and bottom of sumo instead of the sides. This would make pulling/pushing units easier as they'd be pulled/pushed upwards.

sprunk commented 6 years ago

Related: https://github.com/ZeroK-RTS/Zero-K/commit/72f11bf1ade64e5ca540dd2693b51886e1ae6df2

sprunk commented 3 years ago

Closing because this ticket is buried, changing engine friction is scary (for leveler reasons), and #4473 is more useful because in addition to acknowledging the problem it has a specific implementation proposal.