Hey all so I ran into this issue here.
Here’s a quick video to summarize it:
Let me know if you need any more details.
Thanks for your help in advance!
Hey all so I ran into this issue here.
Here’s a quick video to summarize it:
Let me know if you need any more details.
Thanks for your help in advance!
I’d like to thank both of you so much for all your help! I finally fixed it!
For anyone else suffering from these issues,
Use FixedUpdate()
and Time.fixedDeltaTime
for physics and movement!
These changed EVERYTHING!
I got 144fps both in the editor and on a standalone build.
The actual gameplay is now 1:1.
Originally, I didn’t want to use FixedUpdate()
that much because it looked like all the movement was jittery. Although I think Time.fixedDeltaTime
was the trick to fix that.
I did tweak some project settings but to no avail. It was FixedUpdate()
and Time.fixedDeltaTime
that fixed everything!
Thanks for your help!
Aha! And that's why it's always a good idea to show your code. ;) You have stumbled upon the correct paradigm for managing physics-related activities: Get your input in Update and drive anything physics-related in FixedUpdate. Still not sure why it impacted framerate in the way it did, but I'm glad you got it sorted out!
– ErythriteNo worries and I'm glad that video helped you!
– PeekHey y’all, I seem to be struggling with the same thing. I have a spaceship flight sim going on right now, and here’s the code to move:
void Thrust() {
if (Input.GetAxis("Accelerate") > 0 && !atWall)
{
transform.position += transform.forward * Speed * Time.fixedDeltaTime * Input.GetAxis("Accelerate");
}
else
{
Speed = baseSpeed;
isBoosting = false;
}
if (Input.GetButton ("Turbo") && canBoost && !atWall) {
Speed = boostSpeed;
isBoosting = true;
Debug.Log ("pressing space");
} else {
//turn off boost when not pressing the button
Speed = baseSpeed;
isBoosting = false;
}
}
So not only is the physics being handled under fixedUpdate, but the if statements handling the input as well. It fixed the timing issue in the editor when I hit the play on the spaceship scene, and when I start on the main menu and transition to the ship scene.
And here’s the code for using the boosters:
if (isBoosting) {
//use boost
Stamina -= staminaMultiplier;
} else if (!isBoosting && Stamina < maxStamina && canRegen) {
//recover boost. canBoost basically caps so you cant go over 100 when you're resting
Stamina += staminaMultiplier;
} else {
}
But yet when I compile/build the game, I noticed that the stamina/fuel for using the boosters goees down/fills up around 10x slower than it does in the editor? Despite having fixed the continuity error between scenes in the editor already. I’m still confused as to why FixedUpdate and fixedDeltaTime don’t seem to be working when compiled into the exe
© 2022 - 2024 — McMap. All rights reserved.
@AlwaysSunny Hey could you help me with this? ^ ~The guy you helped make the third person camera a while ago :)
– BigheadIf this is using physics, you shouldn't really be using
– FermentativeUpdate()
as the physics don't update themselves every frame. Have you tried porting the physics toFixedUpdate()
withtime.fixedDeltaTime
instead?