Improvement of switching Movement types

Hi guys,

when I applied the Ben wrote into my Unity game than I had the very strange issue that my character would suddenly move to the last point I clicked with the mouse, or pressing ‘G’ wouldn’t respond right.

There’s a really easy fix to that. All you have todo is:

private void ProcessMouseMovement()
    {
        if (Input.GetMouseButton(0))
        {
            [...]
        }
        else
        {
            //prevents the character going crazy
            currentClickTarget = transform.position;
        }
}

And that’s it. Hope it will help.

Privacy & Terms