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.
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
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.
Then perhaps the rest of the game does use Time.deltaTime or FixedUpdate, while your enemy scripts do not?
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?
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.
Thread maybe old, but it was top result in ‘search engine’
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
Old:
direction = forward * currentSpeed;
New:
direction = forward * currentSpeed * Time.deltaTime;
hahahahaha Such a simple but annoying solution, thank you all, you helped me too