Moving slower on iPhone than in Editor?

Ok so I’m using transform.Translate to move my enemies. In the editor I have the speeds of the different enemies set, but when I put it on the iphone and play it the enemies move a lot slower than they should, the only way to get them moving the same speed on iphone is to multiply there speed by like two, but then I can no longer test in the editor. is there something I’m missing or is it a bug. Whats weird is everything else works perfect.

1 Like

Thats normal, the editor does not reflect performance in any form, your pc is pretty granted 4-16 times faster than the actual device (depending on the device and what you do.

What you need to do is make your moves framerate independent so you define a move per second and then multiply that when applying by Time.deltaTime

1 Like

But on the device the rest of the game isn’t moving any slower and my players speed is exactly the same, the only things that move slower are objects moving with transform.Translate.

1 Like

Then perhaps the rest of the game does use Time.deltaTime or FixedUpdate, while your enemy scripts do not?

1 Like

So if I were to do something like this (transform.Translate(Vector3.forward * speed * Time.deltaTime)) it should run the same in the editor and on the device?

1 Like

Yes. Multiplying by Time.deltaTime means you are multiplying by the fraction of a second the frame lasts for. Therefore it becomes frame rate independent. You will probably have to change the speed variable to get back to your original Editor speed, but then you will have a consistent speed across all devices.

1 Like

Thread maybe old, but it was top result in ‘search engine’ :wink:
And it works !
Same as above, bosses were moving slower on iPhone than PC, tried everything to fix, didn’t realise i had missed out the Time.deltaTime after i rewrote the scripts. Saved me from getting a huge headache, and hope it continues to help others :slight_smile:
Old:

direction = forward * currentSpeed;

New:

direction = forward * currentSpeed * Time.deltaTime;
2 Likes

hahahahaha Such a simple but annoying solution, thank you all, you helped me too