fa icon indicating copy to clipboard operation
fa copied to clipboard

Working prototype of an alternative way for units to crash to the ground

Open Garanas opened this issue 7 months ago • 6 comments

This is very much a draft at this moment

How units crash is a bit of a web at the moment. There's the sinker projectile and the shield collider projectile. And then there's units with death animations. And all of that comes together with a lot of overhead, such as closures and threads and a lot of table operations.

I've been wondering: could we do this different? And the answer is: yes we can!

Features:

  • [x] (1) A generic crash component
  • [x] (2) A generic crash projectile
  • [x] (3) All units that are ballistic can now bounce off shields
  • [x] (4) All units can now technically crash
  • [x] (5) All crashing units inherit their velocity when they start crashing

Fixes:

  • [x] Hover units create wrecks that are on the ground now

Todo:

  • [ ] (1) Integrate with death animations
  • [ ] (2) Add functionality to create explosions
  • [ ] (3) Add functionality to create debris
  • [ ] (4) Apply death weapon damage to shields that it bounces off
  • [ ] (4) Adapt the functionality of (2) and (3) so that you can customize it on a per-unit basis
  • [ ] (5) Add functionality to manipulate the fall direction based on damage taken

Problems:

  • [ ] What to do with units attached to a transport and the transport died?

Garanas avatar Jan 05 '24 11:01 Garanas

As an example of Add functionality to manipulate the fall direction based on damage taken, we can give the damage direction to the crash component and apply it to the initial velocity of the projectile. We can make hover units (or any aerial-like unit) interact with the explosion that destroyed it! As a quick example, this hover tank jumps up wards before it crashes:

https://github.com/FAForever/fa/assets/15778155/e843a997-cc14-4898-8670-6867554343c7

And all it took was this:

    Crash = function(self)
    
        -- (...)

        -- inherit the unit velocity
        crashProjectile:SetVelocity(uvx, uvy + 4, uvz) -- note the + 4

        -- (...)
    end,

We just need to feed it the correct direction (from OnDamage) and we're done!

Garanas avatar Jan 05 '24 11:01 Garanas

An example of the shield Bounce:

https://github.com/FAForever/fa/assets/15778155/0196f12d-bc85-478c-ac8c-b1437c47ce9c

Garanas avatar Jan 05 '24 11:01 Garanas

Hi. If I am allowed to give some constructive criticism, the shield bounce does not look right. There seems to be a small delay before the bombers bounce back. Also they bounce back too far compared to normal.

RabidPope avatar Jan 08 '24 06:01 RabidPope

the shield bounce does not look right. There seems to be a small delay before the bombers bounce back.

Yes, there's a single tick where it hiccups at the moment. We'll fix that in the future 😃 .

Also they bounce back too far compared to normal.

That is adjustable with a parameter!

And of course, all feedback is welcome.

Garanas avatar Jan 08 '24 06:01 Garanas

would this finally stop the death donut from feeling like it directly targets something expensive to fall on when it dies? (seriously I have never seen a Czar not fall on something valuable unless it gets shot down faaaar from anything it can land on)

VaelophisNyx avatar Mar 10 '24 05:03 VaelophisNyx