Characters start running when switching to Mouse Mode

So, I had this issue where I could click to walk around, then hit ‘G’ and use WASD to move around.
If you hit ‘G’ again, the character would immediately start running back to the last clicked position.

My solution was to clear the clicked position every time ‘G’ is pressed. It might not be necessary to do this when going from click to WASD/gamepad mode, but this while line will be moved to a menu later anyway…

	private void FixedUpdate()
{
	if (Input.GetKeyDown (KeyCode.G)) { // G for gamepad. TODO add to menu
		isInDirectMode = !isInDirectMode; // toggle mode
		currentClickTarget = transform.position; // reset click position
	}
4 Likes

Hi Dave, I did the same but I’ve putted the line of code in small method, called ResetClickTarget, since we’re doing the assign multiple times. :slight_smile:

Privacy & Terms