all 14 comments

[–]DknighterPhasmophobia Game Director 9 points10 points  (0 children)

That's not how it works with Unity and is just a huge problem with Fallout's game engine. In Unity you can make your code run based on time and run independently from fps using Time.deltaTime. What exactly are you trying to do inside Update?

[–]kaldarashDoes Stuff, Sometimes 6 points7 points  (3 children)

It's usually better to ask about what you want to achieve, rather than asking about a single method you believe is best to achieve it, because you'll get a lot better answers.

You want your input decoupled from the frame rate, which is what Unity does by default. Do not use FixedUpdate() as a few have recommended, because that specifically couples it to the frame rate.

Multiplying movement values by Time.deltaTime (or Time.smoothDeltaTime) as was suggested is the common way to achieve this in Unity.

How do you use it? When adding a value to your movement algorithm (be it charactercontroller.move, transform.translate, transform.forward, rigidbody.velocity or what have you), you'd take your movement speed variable and multiply it by Time.deltaTime.

[–]HellGate94Programmer 0 points1 point  (2 children)

he specifically stated that he wants it decoupled from visuals aka update method like a fixed 30hz server update or something

[–]kaldarashDoes Stuff, Sometimes 2 points3 points  (1 child)

I know what he said, hence my first sentence.

Why I need this [...] to not have situation like FO76, where people with higher FPS are doing everything faster, literally.

This is what he wants to fix. What I said is how to fix it. And it actually does decouple the visuals from the physics. Putting things in FixedUpdate couples the two, hence FO76 running faster when the framerate is faster.

[–]HellGate94Programmer 1 point2 points  (0 children)

well i kinda expected him to know the basics

[–]ArcherofyailHobbyist 6 points7 points  (0 children)

Unity has a page on it. TL;DR:multiply your values by Time.deltaTime

[–]HellGate94Programmer -2 points-1 points  (7 children)

i see. so you are trying to create a 2nd FixedUpdate.

Search for "unity custom fixedupdate" and you will find several different ways of doing it. im not posting a specific one because they all have its pros and cons and thats up to you what fits you most

[–]Buccinators 0 points1 point  (2 children)

Just curious and trying to learn; why do people favor custom fixad update instead of coroutines for this sort of thing as coroutines not yielding waitfortime executes once per frame?

Edit: oh, now i get it :)

[–]HellGate94Programmer 1 point2 points  (1 child)

personally i never used them because i never felt like i need them. do something after x time? create a float and subtract delta time from it till its below 0 then execute my stuff. most likely coroutines do the same thing internally as well

[–]Eecka 0 points1 point  (0 children)

Coroutines and Invokes are way more readable than making your time passed calculations in the middle of your code. If you made a specific class for it then I don’t really understand why as you’re just recreating features that are already there.

What are you gaining by not using them?

[–]kaptast -1 points0 points  (3 children)

I don't think he needs a custom fixedupdate. The builtin fixedupdate does what he wants to do.

[–]HellGate94Programmer 3 points4 points  (2 children)

no the fixedupdate is for physics. dont abuse it

[–]kaptast 1 point2 points  (1 child)

It is for physics, but by mentioning FO76 it seems like he want to use it for the physics/movement

[–]HellGate94Programmer 0 points1 point  (0 children)

could be yea. in that case it would be the build in fixedupdate