public void UpdateSlots() { Agent leader = pattern.leader; Vector3 anchor = leader.position; float orientation = leader.orientation; foreach (SlotAssignment sa in slotAssignments) { //Debug.Log ("Analizando Slot Assignment #" + sa.slotIndex); AgentNPC character = sa.character.GetComponent <AgentNPC>(); if (character != leader) // Tiene sentido que el lider no se mueva { //Debug.Log ("Analizando slot de " + character.name + " en el patron " + pattern); Vector3 slotPos = pattern.GetSlotLocation(sa.slotIndex).position; Vector3 relPos = anchor + leader.transform.TransformDirection(slotPos); // Debug.Log(sa.slotIndex + ". SlotPos: " + slotPos + ", relPos: " + relPos); Location charDrift = new Location(relPos, orientation); // charDrift.position += driftOffset.position; // Debug.Log("driftOffset.position = " + driftOffset.position); // charDrift.orientation += driftOffset.orientation; //Podria ser * // Debug.Log("ASIGNANDO A " + character.name + " LA ORIENTACION " + orientation); character.SetFormation(charDrift.position, orientation); //Queremos que miren a donde mire el lider } } }
//update the slots public void UpdateSlots() { GameObject leader = pattern.leader; Vector3 anchor = leader.transform.position; Vector3 slotPos; Quaternion rotation = leader.transform.rotation; foreach (SlotAssignment sa in slotAssignments) { Vector3 relPos = anchor; slotPos = pattern.GetSlotLocation(sa.slotIndex); relPos += leader.transform.TransformDirection(slotPos); Location charDrift = new Location(relPos, rotation); Character character = sa.character.GetComponent <Character>(); character.SetTarget(charDrift); } }