supertux icon indicating copy to clipboard operation
supertux copied to clipboard

Wind and swimming updates

Open biggeryetbetter opened this issue 1 year ago • 40 comments

This PR includes an overhaul of wind physics: Included changes:

  • Player doesn't jitter in certain scenarios with wind
  • No skidding noise in wind.
  • Player is not slowed down when they work with wind.
  • Most flying enemies can now interact with wind
  • A "Current" variant of wind that does not affect Dive Mines.
  • Wind acceleration and speed is now part of the Physic class for convenience.

biggeryetbetter avatar Feb 20 '24 23:02 biggeryetbetter

A issue that does still persist is that when the wind is set to values (I believe) below Tux max. walk/run speed, Tux will not be moved by the wind when standing still, stuck in his run animation.

Also, I feel that wind should always affect things when they are in their zone. Right now if you don't jump it will not affect you at all, even though you are clearly inside the wind zone.

https://github.com/SuperTux/supertux/assets/20615048/a5823825-2fb1-44d5-8e3b-91ed76a7da46

Rusty-Box avatar Feb 23 '24 11:02 Rusty-Box

I have made several changes to the wind physics process that seem to have fixed these behaviors. I've also added a prototype "current" that does not affect dive mines. I would like some clarification about what you mean in #2592:

You have better control within the current for better navigation and correcting

By this, do you mean faster acceleration/deceleration?

biggeryetbetter avatar Feb 23 '24 19:02 biggeryetbetter

So the thought behind the current was that (since it is underwater) it can be used to suck/push Tux into an area. However, Tux should be able to swim against the current if it is not too strong. Now that should probably apply to both the current and wind. Main difference is that the current type would have different particles (i.e. bubbles) to better fit the aquatic theme.

Rusty-Box avatar Feb 23 '24 20:02 Rusty-Box

Somethig I noticed with the "Current". It is very hard to fight it. Especially with an acceleration of 100. You would expect setting the speed of wind lower than Tux's swim/boost speed, he'd still be able to slowly go against the current. However, I seemingly get force-halted by the current even thought techincally Tux should still be able to swim through (obviously slower). It lets me swim for a short moment before halting all my progress, even when oosting which is moves very fast! Even with an acceleration of 10.

https://github.com/SuperTux/supertux/assets/20615048/9c560152-edef-4080-bc6b-9b4ed24145bd

Also, make sure to have the "Current" particles fade out rather than suddenly disappearing in an instant.

Rusty-Box avatar Feb 23 '24 20:02 Rusty-Box

I would not be suprised if something similar applies to the normal wind as well

Rusty-Box avatar Feb 23 '24 21:02 Rusty-Box

I'm admittedly a bit stuck on this issue. While the normal wind seems to be working correctly, it seems that in water, the acceleration from current is still vastly overpowering that from swimming. Unfortunately I'm not really sure how to fix that without also altering how swimming works- any ideas would be appreciated.

biggeryetbetter avatar Mar 04 '24 02:03 biggeryetbetter

Unfortunately I'm not really sure how to fix that without also altering how swimming works- any ideas would be appreciated.

Altering swimming in what way? Swimming is still a fairly "unpolished" mechanic so alterations are still legitimate as long as they improve it. So depending on how would have to alter it, you might be able to go through with it.

Rusty-Box avatar Mar 04 '24 14:03 Rusty-Box

Alright, I've tried tweaking swimming to actually work with wind. Let me know what you think. Boosting in particular seems to sometimes create large radii on turns which might need to be fixed.

Also, how can I make the water bubbles fade out?

biggeryetbetter avatar Mar 19 '24 16:03 biggeryetbetter

Found a couple bugs:

  • Walking through wind and standing, Tux gets pushed much weaker as when he jumps afterwards

https://github.com/SuperTux/supertux/assets/20615048/db496486-2581-419d-a4ed-f804570aa505

  • When underwater Tux will attempt to always move left when letting go of the directional keys.

https://github.com/SuperTux/supertux/assets/20615048/7908f659-6aa1-400a-9ed1-d474b8dc039d

  • At higher acceleration, around 100 (default value) but also noticeable aroud 50, Tux begins kinda jittering in a current and also somewhat stop an go when at higher speed wind

https://github.com/SuperTux/supertux/assets/20615048/1b5d0fbf-a4d6-4497-b205-362b3c1251a9


It also seems that the wind affect Tux statically, i.e. instead of his speed accelerating or decelerating "smoothly" it changes instantly. Atleast that's how it felt to me. It should ease into the new faster/slower speed to make the transition more smooth. This seems to apply to both wind and current, if that is truly what is happening, maybe I'm mistaken here.

Rusty-Box avatar Mar 20 '24 16:03 Rusty-Box

I can confirm the first and third bugs but I'm not able to recreate the second one. Can you upload the setup that is shown in the video?

Another bug: Pressing the down arrow rapidly while moving into fast wind somehow allows you to go through easier. This is caused by some stuff around line 1586 of player.cpp and I don't know what they are supposed to do so I won't touch them.

biggeryetbetter avatar Mar 20 '24 20:03 biggeryetbetter

Can you upload the setup that is shown in the video?

This is the level I tested and discovered that bug:

wind_test_level.zip

Rusty-Box avatar Mar 24 '24 14:03 Rusty-Box

More bugs I found:

  • Buttjumping in downwards moving wind breaks the animation, i.e. Tux gets stuck in his buttjump an/or stomp animation after touching the ground.
  • Tux cannot duck when in wind that goes downwards

Rusty-Box avatar Mar 29 '24 23:03 Rusty-Box

I also noticed that when you swim in the Current and you move in the direction it goes, you kinda seem to break the speed at which it is pushing you, like you get a bit slower than when you just get pushed without moving yourself. This might also apply to normal wind. Not sure on that. I usually notice it best while swimming.

Rusty-Box avatar Mar 29 '24 23:03 Rusty-Box

Okay I keep finding many more bugs - sry 'bout that :D

So apparently, Dive Mine is still affected by currents but also when they leave the current/wind area they keep on going, never stopping. Also getting pushed underwater is still somewhat jittery. Feathering help a little bit but overall needs a much higher value than normal wind to be smoothed out fully, for the most part.

Speaking of feathering, so idk if I fully get what it does specifically but the best values I've seen with it seems to be around 350? Can shed some more light on what it does exactly because with default value of 16 it looks horribly jittery

Rusty-Box avatar Mar 29 '24 23:03 Rusty-Box

Don't worry; that's what open-source is all about. I haven't done a particularly good job testing each change, to be honest.

Also, the way feathering works is that it calculates how far the center of your hitbox is from the edge of the wind area (in pixels), then divides it by the feathering distance and clamps it between 0 and 1. It wasn't introduced to fix the jittering (that is caused by friction) but rather the fact that tux would keep "bouncing" off the edge of strong wind instead of pushing up against it like you might expect.

My main problem with how it works right now is that if you put wind in a tunnel, like in the test level you showed previously, the top and bottom edges of the wind will have feathering, even though this makes no sense inside a tunnel.

Also, I found out that I was calculating m_wind_velocity (should actually be m_wind_acceleration) completely wrong which seems to have been what was going on when you said

It is very hard to fight it. Especially with an acceleration of 100. You would expect setting the speed of wind lower than Tux's swim/boost speed, he'd still be able to slowly go against the current.

I will keep attacking these issues and hopefully we can get this to work soon!

biggeryetbetter avatar Mar 31 '24 18:03 biggeryetbetter

Any further progress on this? Just checking :)

Rusty-Box avatar Apr 13 '24 18:04 Rusty-Box

Not really as I have again been busy with other things. It seems like the cause of the weird jittering bug is that wind only collides with tux every few game ticks and adds velocity, in between which, friction causes tux to suddenly slow down. That is what I have been stuck on currently.

biggeryetbetter avatar Apr 13 '24 23:04 biggeryetbetter

Alright I think I got the jittering issue fixed finally... Sorry that took awhile. Let me know what you think and of any bugs you find.

biggeryetbetter avatar Apr 21 '24 16:04 biggeryetbetter

  • Jittering appears to be fixed indeed. The only thing that happens is that Tux's walk animation start,stops,start,stops the whole time if you don't hold the direction key you're going.

https://github.com/SuperTux/supertux/assets/20615048/1da20ea0-b2c9-4507-b5dd-d073e9441d27

  • Knowing that Tux walk and run speed can go up to iirc. 230 and 320 repsectivly, I'm suprised that if you walk against wind with a 100 value Tux barely manages to walk against it. As if the wind was suddenly way stronger. Also when Tux jumps still gets pushed stronger than when he is on the ground, which is odd.

https://github.com/SuperTux/supertux/assets/20615048/a869c117-5fa0-4745-9526-eff5089649ce

  • Reaching the top of a wind area occassionally push Tux much higher + objects that walk or stand in up facing wind don't get pushed up. They're not even affectd by wind at all even the they should

https://github.com/SuperTux/supertux/assets/20615048/7e7680c7-27ff-4240-9057-21f8cf3e6edc

https://github.com/SuperTux/supertux/assets/20615048/496f1026-a648-4f7e-a13c-daae5fef3e27

Rusty-Box avatar Apr 22 '24 17:04 Rusty-Box

I've been procrastinating on this a lot but I have finally gotten around to letting the vast majority of badguys interact with wind. I have not done this for ice crushers and ghouls because I'm not sure if that is desired. Unfortunately, due to changes in how strong acceleration is, levels like "A Leaf In the Wind" will be broken with wind in its current state; the "acceleration" option will need to be cranked up quite a bit. Wind is however much more consistent with other sources of acceleration such as gravity, which is 1000 px/s^2 by default and can be mostly negated by using a wind object pointed upwards with an acceleration of 1000. For this reason I would personally recommend that levels simply be updated. Let me know what you think about this and the icecrushers/ghouls.

biggeryetbetter avatar Jul 10 '24 17:07 biggeryetbetter

I have not done this for ice crushers and ghouls because I'm not sure if that is desired.

Sounds fine. Ghoul is a ghost so makes sense they are not affected really and Crushers don't really need it. At best have them fall slower wind etc but its not too essential.

Unfortunately, due to changes in how strong acceleration is, levels like "A Leaf In the Wind" will be broken with wind in its current state; the "acceleration" option will need to be cranked up quite a bit.

Totally fine. Levelshave been fully remade from scratch for the next update thus will take this changes into account.

I will do further and more proper testing as soon as possible! Thank you for all this effort btw. :)

Rusty-Box avatar Aug 02 '24 23:08 Rusty-Box