/** * Mueve el Scorbot a una posición ya definida. * @param robot Scorbot * @param target Posición (objeto) * @return void */ public void Move(IK robot, Transform target) { // Target with valid data if (target.GetComponent <TargetModel>().GetValid()) { // Move Scorbot to target. It uses "speed" robot.Move(target); } else // Target with invalid data { stateMessageControl.WriteMessage("Error. MOVE Unreachable position \"" + target.GetComponent <TargetModel>().GetName() + "\"", false); return; } stateMessageControl.WriteMessage("Done. MOVE \"" + target.GetComponent <TargetModel>().GetName() + "\"", true); // Online mode if (gameController.GetOnlineMode()) { bool done = controller.RunCommandUIOnline("move", target.GetComponent <TargetModel>().GetName()); if (done) { string aux = ""; if (!target.GetComponent <TargetModel>().GetSync()) { aux = ". NO SYNC"; } stateMessageControl.WriteMessage("Done. Online MOVE \"" + target.GetComponent <TargetModel>().GetName() + "\"" + aux, done); } else { stateMessageControl.WriteMessage("Error. Online MOVE \"" + target.GetComponent <TargetModel>().GetName() + "\"", done); } } }
public void Move(IK robot, Transform target) { if (target.GetComponent <TargetModel>().GetAngles() != null) { robot.Move(target); //Debug.Log("Using angles"); } else { robot.CCDAlg(target); target.GetComponent <TargetModel>().SetAngles(robot.GetAnglesFromCopy()); //Debug.Log("Using IK"); } // if (gameController.GetOnlineMode()) { controller.RunCommandOnline("move" + " " + target.GetComponent <TargetModel>().GetName()); } }
private void Update() { Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; // Select if (Physics.Raycast(camRay, out hit)) { IK ik = hit.collider.GetComponent <IK>(); if (ik) { if (Input.GetMouseButtonDown(0)) { selected = ik; selected.Select(); } } } // Move if (selected) { if (Physics.Raycast(camRay, out hit)) { selected.Move(hit.point); } // Release if (Input.GetMouseButtonUp(0)) { selected.Release(); selected = null; } } }