K
K
Kermzy2018-06-14 09:45:04
Game development
Kermzy, 2018-06-14 09:45:04

Why can the speed of the game in the assembly be very different from the editor in Unity?

Good afternoon!
There is a 2d project consisting of two scenes (menu and main game). The menu contains moving decorative elements. The game itself has elements that use 2d physics. During the development process, periodically made new builds for testing. At a certain stage, I encountered such a problem: when opening an exe file, it seems that time flows much faster (all moving elements are very much accelerated). When moving to the second scene (the game itself), all elements that use physics also do not work correctly (on the contrary, as if slowed down). At the same time, everything is played in the editor of Unity itself, as before, at a given speed. The problem was revealed only when checking the assembly. Between a build where everything was displayed correctly and a build where "everything is sped up" several new prefabs with sound were added and the code for playing them was corrected. Also, during this period, some of the prefabs were accidentally deleted from the Assets folder and then restored from a separate backup. Deleted prefabs were not edited during this interval between builds. When creating an assembly, I tried all possible options for compression and assemblies for developers - the result does not change.
Understanding that most likely there can be many reasons and that it is not advisable to lay out a bunch of scripts, I ask, if possible, to suggest in the direction where it is worth starting to search for the problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2018-06-14
@Kermzy

1) Display the FPS and see
2) When moving, do you take deltaTime into account?
3) Look with a profiler - all of a sudden it's wildly pedaling

K
Kermzy, 2018-06-14
@Kermzy

I checked the fps on your advice, and indeed, in the editor, about 60, and in the assembly, about 2000. And indeed, I completely forgot about Time.deltaTime. It remains unclear why before that in the assemblies fps corresponded to the editor, and the error did not appear, and because of what the supposed limit in assemblies of 60 fps flew off.
Now the question arose of restoring the original speed of all objects, because multiplication by Time.deltaTime, as I understand it, must be performed together with a "correction factor". And a simple calculation =(FPS in the assembly / FPS in the editor) does not give the exact initial speed, because. fps in the assembly varies greatly. In any case, thanks for solving the main problem, the rest is a matter of technology!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question