Could that make a bug?

I wrote different code from this lecture and it is working, but could that make a bug in the future?

In the lecture

void Move()
    {
        Vector3 delta = rawInput * moveSpeed * Time.deltaTime;
        transform.position += delta;
    }

My code

void Move()
    {
        Vector3 delta = rawInput;
        transform.position += delta * moveSpeed * Time.deltaTime;
    }

The two are identical in terms of functionality. I would ask why you even use ‘delta’ in yours?

The way it was done in the lecture, the result in delta is a useful value for future extensions to the Move method. e.g. if you want Move to return how far something moved you could easily create

float Move()
    {
        Vector3 delta = rawInput * moveSpeed * Time.deltaTime;
        transform.position += delta;
        return delta;
    }

So generally I prefer the way it was done originally, although as I say, your alternative is functionally identical.

Privacy & Terms