#Why does my player character not swim horizontally?

1 messages · Page 1 of 1 (latest)

keen barn
#

In my code, I use InputHandler to handle my input, which also determines which action map gets enabled and which gets disabled.

Now what should happen is, my player character should hit a body of water and if that happens, he disables the gameplay action map and enables swimming action map.

What actually happens is, Player enters water, player no longer can move horrizontaly but can move vertically for some reason. And in the code where both movements of swiming execute, Debug.Log shows that player.linearvelocty changes, but the player himself never moves right or left.

I uploaded all related code and a video of the issue. Thank you in advance.

somber quarry
#

Did you constrain x axis motion on your Rigidbody?

#

Also it would be much better to share videos as mp4 so they get embedded in discord

#

And the code with

#

!code

coarse ginkgoBOT
somber quarry
#

Also - cs player.linearVelocityX = MovementSpeed * MoveDirection.x;

#

Isn't this going to keep running after you disable the movement input?

#

Which means it will set the velocity to 0

#

You essentially have two different scripts fighting over setting the velocity

keen barn
#

Makes sense now