Adding Time.deltaTime doesn`t work in Exe

I have a little flying engine here. With ctrl i accelerate, by adding to my speed variable. With shift i decellerate, by substracting from my speed variable

		if ((groundtrigger.triggered==1)(Input.GetButton("Fire1"))(speed<800)) speed=speed+3;

This works fine in the Editor. It runs in the speed i want it to. So i made an exe, and found out that this runs ways too fast in the exe.

Obvously a speedsave code problem. So i changed it to add a Time.deltaTime value instead to get a more speedsave code.

		if ((groundtrigger.triggered==1)(Input.GetButton("Fire1"))(speed<800)) speed+=Time.deltaTime*240;

This works fine in the editor. It runs in the speed i want it to. So i made an exe, and found out that this doesn`t work at all in the exe.

Successfully trapped :lol:

Could somebody please enlighten me what goes wrong? Why does an event that works in the Editor refuse to run in the final exe?

EDIT; Problem solved, example file removed.

It could be that speed is defined as an int. If that is the case, with very high frame rates, Time.deltaTime*240 will drop below 1, which is always 0. If this is indeed the problem, turning speed into a float should solve it.

It could be that speed is defined as an int. If that is the case, with very high frame rates, Time.deltaTime*240 will drop below 1, which is always 0. If this is indeed the problem, turning speed into a float (and maybe changing 240 to 240.0, as I’m not sure how Unity JS handles mixed multiplications) should solve it.

You`re a genious. That was it. Thanks mate :smile:

I just turned the speed variable into float. That was enough changing to make it working in the exe.

Makes me nevertheless wonder why it works in the Editor, and not in the Exe :slight_smile:

The editor usually has the game view tab, scene view tab, hierarchy tab, project, inspector tab that all need to be rendered and updated. That is much more work than the exe has to do, as that just runs the game. Therefore, a game normally runs faster as an exe than in the editor.