First person swimming controller

Hello everyone. I have created a game based on Subnautica and Raft.
I wanted to create a swimming controller, however, I absolutely suck at coding. I was hoping someone could help me with this.
Thank you in advance.

Link to game: https://playcanvas.com/editor/scene/1255024

1 Like

Hi @RumaiIndustries and welcome,

You can start with the following tutorial on how to work with physics, applying forces and impulses to your objects:

https://developer.playcanvas.com/en/tutorials/Using-forces-on-rigid-bodies/

And that’s on way to approach the swimming/floating in the water problem, apply a constant upwards force to your body.

Other ways involve lowering gravity (you can do so in your project settings), or messing directly with your object linear velocity.

i want to do a raft clone too ! ha ha nice idea :slight_smile:

Thank you @Leonidas! I will try this and see if it works.

Hello again @Leonidas! I tried the gravity method and it seems to work, but the character tends to go flying. I also tried the force applying method but it didn’t work. Is there a way I can take the Anti gravity part of the script and attach it to the normal character controller?