コード例 #1
0
    /// Attaches the frisbee to another GameObject (= player).
    public void AttachToPlayer(GameObject player, ThrowSide throwSide)
    {
        DetachFromPlayer();
        playerSelector.DeselectAllPlayers();

        state = State.AT_PLAYER;
        playerHoldingTheFrisbee = player;
        playerHoldingTheFrisbee.GetComponent <PlayerMovement>().canMove = false;

        if (throwSide == ThrowSide.RIGHT)
        {
            transform.position = playerHoldingTheFrisbee.transform.position + Vector3.right;
        }
        else if (throwSide == ThrowSide.LEFT)
        {
            transform.position = playerHoldingTheFrisbee.transform.position + Vector3.left;
        }

        FixedJoint fixedJoint = frisbeeObject.AddComponent <FixedJoint>();

        fixedJoint.connectedBody = playerHoldingTheFrisbee.GetComponent <Rigidbody>();
        fixedJoint.breakForce    = 250;
    }