Skip to main content

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

Thanks for the comment!

Originally the movement was faster but when I export to WebGL the movement was toned down a lot. I even upped the movement speed by 3 times for the WebGL build and it still is a bit slower than in the editor. If you have any idea why this is or how to prevent/fix this I would love to hear it.

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!