Unity: Move object at same rate across platforms

Published: 2020-05-25 18:26:38 -0400 -0400

Reading time: 1 mins (111 words)

Tags: unity framerate crossplatform

problem

I was building a mobile game, coffeedash, and found that when I played my game on an actual mobile device, my character moved a lot slower than it did when I ran the Unity game on my computer.

solution

The problem was that I was moving my object in the Update function. The Unity Update function is called once per frame and you can imagine that the frame rate of a mobile device is likely a lot lower than the frame rate of, say, a gaming computer.

To fix this, you can use the FixedUpdate function which gets called 50 times / second regardless of what device you’re playing on.

About the Ham

Hi I'm Hamilton and I wrote / built this! I like doing lots of things, but mostly I like to build (and then share those buildings). Some things I'm currently building: art, software, and prose. To stay up-to-date with my latest buildings, subscribe to my email list or follow one of my many other accounts. #buildit #shipit #justhamit

comments powered by Disqus