Wednesday, April 8, 2020

Mr Taft FAQ 2 - Player Movement Speed is Choppy/Slow

This is the second in a series of FAQ articles to accompany the Zelda Like Tutorial Series from Mr. Taft. 


The Question:


"Hi guys my player is moving choppy like it is slowing down then going faster after a few seconds I'm not sure what I did wrong?"


The Solution(s):


1. The quick one!


Toggle VSync on in your game options.

Vsync On!

2. The longer (better?) one!


The issue is related to having the movement and animation updating from well, Update(). Update() is called once every frame and by its nature is variable in when it is called unless you are locked in with a VSync which limit's the calling of Update to the refresh rate of your monitor and is why the quick fix above works.

It is better, in my opinion for this tutorial series, to keep the input code within Update() but move the animation/movement code to within FixedUpdate() this occurs at a fixed interval determined by your project settings. Some sample code from my own PlayerMovement.cs is below. 

Excerpt from PlayerMovement.cs



Happy coding! :D

PappaP x

No comments:

Post a Comment

ASP.NET Core(porate) , yup I'm hilarious :|

 So, lately, I have been in full corporate mode. That means looking after my team of engineers and when I have some gaps in my calendar work...

Most Viewed