Speed of the projectiles - Problem when using Time.deltaTime


When doing the challenges in the lesson, I spontaneously thought: well, we kind of adjusted the speed of the spaceship and the enemies with Time.deltaTime so that it does not depend on the refresh rate, so it makes sense to do the same for the laser beams right?

Well… When doing it, I noticed that there was a lot of randomness in the speed of the beams. None was going at the same speed!!! As if the refreshing rate was different for everyone of them… Weird no?

Any explanation as to why we don’t use it and why it does not work properly??? (In theory we would not want to have the speed of the lasers depending on the speed of the computer, right?)

Thanks in advance if you find something!

We implement beam spead by adding a velocty to the object, Unlike moving the beam ourselfs every frame. so by varying it by the DeltaTime(which isn’t constant) you are varying the velocites so it seems all over the place.

1 Like

Clear, thanks!
So actually, it would make sense to apply some velocity to the enemies instead of moving them frame by frame, no? Wouldn’t it improve the performance?

I think it will be more of a hassal because you’ll need to also calculate when to invert the velocity(velocity keeps going indefinitely if no gravity etc.)

Privacy & Terms