//	public override void OnUpdate ()
//	{
//
//	}

    public override void OnLateUpdate()
    {
        if (showError && Time.unscaledTime - errorTime >= 3f)
        {
            showError = false;
        }
//		Debug.Log ( "local" );
        if (Input.GetButtonDown("Reset Quad"))
//		if ( Input.GetKeyDown ( KeyCode.G ) )
        {
            motor.ResetOrientation();
            control.followCam.ChangePoseType(CameraPoseType.Iso);
        }

        if (Input.GetButtonDown("Patrol Waypoint"))
//		if ( Input.GetKeyDown ( KeyCode.P ) )
        {
            PatrolPathManager.AddNode(motor.Position, motor.Rotation);
        }

        if (Input.GetButtonDown("Hero Waypoint"))
//		if ( Input.GetKeyDown ( KeyCode.O ) )
        {
            HeroPathManager.AddNode(motor.Position, motor.Rotation);
        }

        if (Input.GetButtonDown("Crowd Spawnpoint"))
//		if ( Input.GetKeyDown ( KeyCode.I ) )
        {
            SpawnPointManager.AddNode(motor.Position, motor.Rotation);
        }

        if (Input.GetButtonDown("Deactivate Spawner"))
//		if ( Input.GetKeyDown ( KeyCode.N ) )
        {
            spawner.SetActive(false);
        }

        if (Input.GetButtonDown("Activate Spawner"))
//		if ( Input.GetKeyDown ( KeyCode.M ) )
        {
            if (PatrolPathManager.Count < 2)
            {
                showError = true;
                errorTime = Time.unscaledTime;
                error     = "Patrol path needs at least 2 waypoints";
                return;
            }
            if (HeroPathManager.Count < 2)
            {
                showError = true;
                errorTime = Time.unscaledTime;
                error     = "Hero path needs at least 2 waypoints";
                return;
            }
            if (SpawnPointManager.Count < 1)
            {
                showError = true;
                errorTime = Time.unscaledTime;
                error     = "Need at least 1 crowd spawn point";
                return;
            }
            showError = false;
            spawner.SetActive(true);
        }

        if (Input.GetButtonDown("Clear Patrol"))
//		if ( Input.GetKeyDown ( KeyCode.L ) )
        {
            PatrolPathManager.Clear();
        }

        if (Input.GetButtonDown("Clear Hero"))
//		if ( Input.GetKeyDown ( KeyCode.K ) )
        {
            HeroPathManager.Clear();
        }

        if (Input.GetButtonDown("Clear Crowd"))
//		if ( Input.GetKeyDown ( KeyCode.J ) )
        {
            SpawnPointManager.Clear();
        }

        Vector3 input = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Thrust"), Input.GetAxis("Vertical"));

        Vector3 inputVelo = new Vector3(input.x * moveSpeed, input.y * thrustForce, input.z * moveSpeed);

        Vector3 forward = tr.forward;

        forward.y = 0;
        Quaternion rot = Quaternion.LookRotation(forward.normalized, Vector3.up);

        rb.velocity = rot * inputVelo;
        Vector3 euler = tr.localEulerAngles;

        euler.x             = maxTilt * input.z;
        euler.z             = maxTilt * -input.x;
        tr.localEulerAngles = euler;

        float yaw = Input.GetAxis("Yaw");

        if (yaw != 0)
        {
            tr.Rotate(Vector3.up * yaw * turnSpeed * Time.deltaTime, Space.World);
            camTransform.Rotate(Vector3.up * yaw * turnSpeed * Time.deltaTime, Space.World);
        }
    }