Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Sorry for the late reply! Here is my suggestion taking from the Gamedev.tv 2D Unity Course.

For my game I used a Velocity of the Rigidbody and multiplied it with the input of the keyboard. Afterward used a Math.f Method to make sure that the Velocity will always round out to a Whole Number. Here is the example code.


Vector2 moveInput;

Rigidbody2D myRigidBody;

[SerializeField] float runSpeed = 10f;


 Vector2 playerVelocity = new Vector2 (moveInput.x * runSpeed, myRigidBody.velocity.y);

        myRigidBody.velocity = playerVelocity;

        

        bool playerHasHorizontalSpeed = Mathf.Abs(myRigidBody.velocity.x) > Mathf.Epsilon;

Hope that helps a little. :)

(+1)

Thanks for the reply anyway. I am not certain it is in the movement speed. It might have to do with a way lower framerate on WebGL and not taking the Time.DeltaTime into account? If that's the case then your reply has helped me to think deeper on it anyway so help is always appreciated!