Ejemplo n.º 1
0
    void Update()
    {
        // Rotate player to match mouse target
        mousePoint = MouseUtils.GetMouseLookPoint(player.transform.position.y);
        player.LookAt(mousePoint);

        // Crosshair targets the look point
        crosshair.transform.position = mousePoint;

        if (GameManager.Instance.DebugMode)
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            Debug.DrawLine(ray.origin, mousePoint, Color.yellow);
        }

        // Player movement
        Vector3 moveInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));

        velocity = movement.GetTargetVelocity(moveInput.normalized);
        player.Move(velocity);
    }