Is it bad performance wise?


Here is one of my scripts. It is used to adjust the speed based on player’s inputs and current actions. Is it too much nodes being used so often? Every single on of them is crucial and cannot be deleted. It checks 1/3 of them every time the player clicks either W, A, S or D.

hi,

whenever something related to player.it must worth to do.

performance issues basically happen when there’s too many instances of the blueprint.

the player is just a single one.so basically your kind of hard to see its influence on performance.

Not really. It isn’t good, but:

  • It only happens on-input (which means it only happens when it’s actually needed so it’s not gonna be slowing down your game when it’s not in use)
  • You’re just setting and getting variables, and not really that many, those are generally speaking very fast operations.
  • You’re not using any loops(for/while) or timelines, e.g. code that executes many times each time this function is called, which tend to be one of the main reasons code would slow down

If/Else chains like this only truly become problematic if they are humongous, but this is a fairly normal size.

You don’t really have to worry about the performance yet, although if I were you and if I wanted to optimize this, I would try to either swap out some of the branch nodes for select nodes; or swap out all the branch nodes for one switch/case node per event.

This video covers quite well how/when if/else chains can become performance drains.

Your code imo isn’t really in that ballpark yet. It’s fine, if it works it doesn’t need more work.

I would advise you to try to optimize it anyways though, because you lose nothing and gain experience from it.