Ejemplo n.º 1
0
    private void MouseControl(PlayerBehaviour player)
    {
        float mousePosX = Camera.main.ScreenToWorldPoint(Input.mousePosition).x;
        float mousePosY = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;

        float distance = Vector3.Distance(player.GetPosition(), new Vector3(mousePosX, mousePosY, player.GetPosition().z));
        //rotationSpeed = rotationSpeed * (distance / 0.8f) * Time.deltaTime;
        if (distance > maxMovementSpeed) {
            distance = maxMovementSpeed;
        }

        player.Move(Vector3.MoveTowards(player.GetPosition(), new Vector3(mousePosX, mousePosY, player.GetPosition().z), movementSpeed * (distance / smoothMotion) * Time.deltaTime));
        //ship.transform.position = Vector3.MoveTowards(ship.transform.position, new Vector3(mousePosX, mousePosY, ship.transform.position.z), movementSpeed * (distance / smoothMotion) * Time.deltaTime);
    }