Ejemplo n.º 1
0
        //create all the connections between the child nodes of a rigidbody (it is assumed they can all walk to each other without interruption)
        public static void AddInternalConnections(Node rb)
        {
            Node lastNode = null;

            foreach (Node n in rb.internalNodes)
            {
                if (lastNode != null)
                {
                    n.addConnection(new Connection(lastNode.index, (lastNode.position - n.position).Length(), CONNECTION_TYPE.WALK));
                    lastNode.addConnection(new Connection(n.index, (lastNode.position - n.position).Length(), CONNECTION_TYPE.WALK));
                }
                lastNode = n;
            }
        }
Ejemplo n.º 2
0
        //create the connection from rb1 to rb2 if there is one between their child nodes
        public static void AddConnectionsFromTo(Node rb1, Node rb2)
        {
            //find out if any of the node's children are connected to the other node's children
            //if not then exit early
            CONNECTION_TYPE connection = GetConnectionBetweenRigidBodies(rb1, rb2);

            if (connection == CONNECTION_TYPE.NONE)
            {
                return;
            }

            float cost = (rb1.position - rb2.position).Length();

            //other costs can be included here, such as taking into account the type of motion required (jump/fall/walk), or looking at the properties of the rigidbodies such as friction or bounciness
            rb1.addConnection(new Connection(rb2.index, cost, CONNECTION_TYPE.HIGH_LEVEL));
        }