コード例 #1
0
ファイル: RopeScript.cs プロジェクト: kidding8/Swing-It-Git
    private void RemoveLastNode()
    {
        nodeList.Remove(lastNode);
        NodeScript oldNodeScript = lastNode.GetComponent <NodeScript>();

        if (oldNodeScript != null)
        {
            oldNodeScript.RemoveLineTarget();
            oldNodeScript.DestroyNode();
        }
        lastNode = nodeList[nodeList.Count - 1];
        //lastNode.GetComponent<SpriteRenderer>().color = Color.white;

        HingeJoint2D hingeLastNode = lastNode.GetComponent <HingeJoint2D>();

        hingeLastNode.enabled = true;
        Rigidbody2D playerRb = player.GetComponent <Rigidbody2D>();

        hingeLastNode.connectedBody = playerRb;
        nodeCount--;

        NodeScript nodeScript = lastNode.GetComponent <NodeScript>();

        if (nodeScript != null)
        {
            nodeScript.SetNewLineTarget(player.transform);
        }
    }