示例#1
0
    private void UpdateWaypointMovement()
    {
        if (Input.GetMouseButtonDown(0) && Input.mousePosition.y > coordinates.GetSeparator())
        {
            // waypoint = Input.mousePosition;
            waypoint = cam_utils.CameraPosToWorld(Input.mousePosition);
        }

        if (waypoint != Vector2.zero)
        {
            var new_pos = Vector3.MoveTowards(gameObject.transform.position, waypoint, (float)speed * Time.deltaTime * 5);
            gameObject.transform.position = new_pos;

            if (new_pos.x == waypoint.x && new_pos.y == waypoint.y)
            {
                waypoint = Vector2.zero;
            }
        }
    }