Torque Issues Game to Game

From time to time it seems my torque settings became much stronger or weaker with me not changing anything, however I stuck with it and just put up with it.

Got my game to a “final draft” stage with all controls stable and usable and then published it via WebGL. The published version though has a very different torque setting/rotation reaction than when in Unity. Any idea why?

I feel it might have something to do with resetting values or something on playthrough? I’d love any help as I’m lost!

1 Like

I had the same problem, so I dug around a bit, while I don’t know what caused it (might be frame rate related), but here’s how to fix it:

Change “void Update()” in the “PlayerController” to “void FixedUpdate()”, this should make the performance in the editor the same as in the WebGL version, you can then adjust torque accordingly.

1 Like

Thank you and I’ll definitely try that. Any chance while I have you here do you know how to get my code from Visual Code Studio to automatically adjust the values in the Inspector? If I code a line saying x = 1f but the inspector has it saying 5 then it defaults to 5… even if I run the program?

Hi Thomas,

@Mou_Leo also told you a potential solution for the problem with the torque. I just want to add that, if you use Time.deltaTime in the FixedUpdate method (or methods that get called in the FixedUpdate code block), remove it. Time.deltaTime must not be used in the context of LateUpdate.

Regarding the problem with values in the Inspector, they are not supposed to get updated automatically just because you changed something in your code. Imagine you had hundreds of enemies, NPCs or something else using the same script. And you spent hours configuring all those game objects in your scene. Would you want to lose your work just because you made a change in the code? Probably not.

When you assign a script to the Inspector, the Inspector takes control over the fields. It just uses the initial values from your code when the component gets created.

If you need to reset the component in the Inspector to get the default values from your code, click on the three dots, then on “Reset Component”.


See also:

Okay, great. I think I’m understanding. This means that when run, the game will run with whatever values are in the Inspector. If I want the Inspector to run at the written code values, I press the reset option?

Also, when I do a final build and publish, what values will be included? The code or the inspector?

If I want the Inspector to run at the written code values, I press the reset option?

Exactly. The reset option makes the Inspector take the values from your code. It’s like adding a new component.

Also, when I do a final build and publish, what values will be included?

Both the values from your code and the values in the Inspector. If you created a scene with a player and set, for example, the player’s health to 5 in the Inspector, the build will use 5. Not 3, which you defined in your code.

However, if you instantiate a new player during runtime, the value will be 3 because you created a new object that does not have anything to do with the Inspector.

Thank you so much, that explains it perfect. Much appreciated about how swiftly you got back to me and how clearly you made the explanation. I’m sure you’ll hear from me in the future for my next challenge I need help with - thanks again :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms