idk once per frame is like seems tolling
Are you asking how costly Update is for the game?
Depends on what you put in your Update call.
It certainly can be expensive if you put a lot of stuff into an Update call.
But certain tasks REQUIRE being done in the Update, there’s no other way around it. Such as reading the users input, and moving the player’s avatar around screen.
If you don’t need to do things once per frame, then don’t use Update(). There’s nothing saying you HAVE to use it.
@lordofduct what about an if statement? like what if theres a bunch of stuff in the if statement, does the void update read all that stuff without if even activating
If the if statement resolves in a manner to NOT do the work inside it, then that work is not done.
It’s still more expensive than not having Update called in the first place.
But as I said… work that requires Update requires it… don’t concern yourself with how expensive Update is in general, it’s about the job you need to get done!
You want to know what the most efficient code is? NONE… takes zero work to do zero things. But… I’m willing to expect you want things to get done.
One thing I see often with new users of Unity is the overuse of Update. (for example, setting text over and over when the value doesn’t change, or checking if a player is dead…instead of just checking when the player takes damage if their health is negative).
As @lordofduct said, there are things update is designed for and you need to use it for that. But, just always think if there is something in your update that actually doesn’t need to go in there because you know you don’t have to check for it every frame.
@lordofduct
“It’s still more expensive than not having Update called in the first place.” i dont know what this means, but thanks for the rest of your explanation ![]()
He means that having an update that does nothing is more expensive than not having an update at all.
@AcidArrow ty
must be a miniscule amount tho ![]()