Let's go for a swim!
There aren't many tutorials for swim in 3D. I basically found one so I use his implementation, which I also need to modify my State Machine to be able to work with his method.
She can walk/run/jump into the water until it reaches her chest and she will float on the surface. She can move around slowly on the surface or swim breastroke style by pushing a button.
I have an area3D at her chest to detect the difference between water surface and her. I use that number to indicate where she is from water surface and what to do. For example when she is closed to the surface, I slowly float her up. If she's far down she will be in underwater state and float in place..etc.
The downside is I can't go anywhere else below the water surface, Maybe need a check somewhere outside of water area to deactivate her swimming state.
The tutorial also uses her velocity to decide what to do as well. For example if her velocity.y is almost zero then go to floating state..etc.
She can dive to underwater. It's kinda tricky to get the animation to match the timing before changing state. There is a way to code it in the tutorial but I didn't add to it yet. Maybe will come back to it later.
She can slowly move or swim on / under / up to the surface. There is a little bug for swim up, if you let go of the button she will stay still but won't change her legs kicking state)
Swimming back to the beach and going to the pool
The Swimming pool has a springboard. Once gets on she can jump very high. It's just an Area3D at the tip and increase jump velocity. The board have bounce animation but it finishes too quickly to see.
Just had to add jump out of pool temporary because I forgot to add a pool ladder.
Swimming has a lot of room to improve but I'm very happy to make it work (always been a goal of mine). I can say that my main objectives here are pretty much completed. I feel I've learned so much game making with this project. (It's not easy as the project gets bigger, your codes get messier). I will put a break on this but will come back to this occasionally to add other interaction stuffs, if I have free time.
I now plan to complete small, actual game project and try to test publish it. (Maybe just a sidescroller in 3D with like 4-5 levels) Also plan to learn to make a 3d fighting game. See you next time!