Q
Q
QmI7052021-01-27 19:51:33
Unity
QmI705, 2021-01-27 19:51:33

What is the best way to implement character movement in Unity?

Let's say I have some move code wrapped in the Move method.
What is the best way to call this method?

void FixedUpdate()
{
  if(Input.GetKey(Keycode.A))
    Move;
}
or
void Update()
{
  if(Input.GetKey(Keycode.A))
    Move;
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
GavriKos, 2021-01-27
@GavriKos

It is enough to read how these two methods differ and turn on the brain a little. There is even a picture somewhere in the manuals about the standard game loop, what is called when and when it is BETTER to check.

F
freeExec, 2021-01-27
@freeExec

And if you open the documentation on Input.GetKey, then the question itself will disappear.

L
Lesh48, 2021-01-29
@Lesh48

If physics is used in move, then FixedUpdate, if not, then just Update.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question