beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
178 stars 95 forks source link

Add a BOS/LUS callin that tells scripts when to start their walk animation #1519

Open GoogleFrog opened 1 month ago

GoogleFrog commented 1 month ago

Previous ticket: https://springrts.com/mantis/view.php?id=4458

spring_XPRRdjaj5Z

Sometimes units can be thrown through the air, land, then move along the ground, all without calling StartMoving. This can be reproduced with weapons that deal a bit of impulse damage, since it only takes a moment of losing contact with the ground to trigger the bug.

This is particularly important for any kind of deployment mechanic that depends on whether a unit is moving or not. But it is also relevant to all units, as any unit can end up skating along the ground this way.

image

I found a reliable way to reproduce it.

Replay:

The replay shows that StartMoving and StopMoving are not adequate for knowing when ground units should play their walk animations. Previous engine devs thought this was working as intended, so perhaps a new callin could be added. I would also be happy for StartMoving to be modified to fix this edge case, so that it was 100% reliable for telling units when to animate.

sprunk commented 1 month ago

Something to be aware of: there's StartSkidding and StopSkidding. Perhaps the engine confuses the two states and only produces events for going from either of them to stationary, but not between moving and skidding?

springraaar commented 2 weeks ago

In MF i have a workaround for this that checks every few frames whether the unit is moving and calls startmoving/stopmoving https://github.com/springraaar/metal_factions/blob/master/luarules/gadgets/unit_physics_handler.lua#L484

in my case startmoving just sets a flag and doesn't trigger piece movement directly. There's a unit scripting thread testing it periodically and handling the animations.

springraaar commented 2 weeks ago

It seems to me that StartMoving is already the callin that does what you're asking.

Apparently the issue to fix is it not triggering when it should, like when the unit started trying to move but it was already moving due to being pushed by external forces.

GoogleFrog commented 2 weeks ago

Ok. I'm responding because you addressed me and I feel like one was expected, but I have nothing to add.

See: https://github.com/ZeroK-RTS/Zero-K/blob/master/scripts/reliableStartMoving.lua

Previous engine devs thought this was working as intended, so perhaps a new callin could be added. I would also be happy for StartMoving to be modified to fix this edge case, so that it was 100% reliable for telling units when to animate.

springraaar commented 2 weeks ago

Ok thanks. I wasn't sure if ZK was using any workaround.

I agree with you but i'd put fixing the current callins ahead of adding new ones.

sprunk commented 2 weeks ago

Figure out whta the current design is and if there is anything to fix by experimenting with Start/StopSkidding.