public void ClearDest() { guideState = TourGuideStates.FOLLOWING; infoMarkerIndex = -1; navMeshAgent.SetDestination(nearPlayer.position); pathCreator.ClearDest(nearPlayer.position); }
public void SetDest(int value) { guideState = TourGuideStates.LEADING; infoMarkerIndex = value; navMeshAgent.SetDestination(infoMarkers[infoMarkerIndex].gameObject.transform.position); pathCreator.gameObject.transform.position = nearPlayer.position; pathCreator.SetDest(infoMarkers[infoMarkerIndex].gameObject.transform.position); }
// Update is called once per frame void Update() { if ((previousPlaceState != ARController.placeState) && (ARController.placeState == GuidedARController.PlaceState.SHOW)) { gameObject.transform.position = startPoint.position; gameObject.transform.rotation = startPoint.rotation; guideState = TourGuideStates.FOLLOWING; navMeshAgent.SetDestination(new Vector3(agentDestination.position.x, transform.position.y, agentDestination.position.z)); } }
void CheckState() { Vector3 target = new Vector3(playerCamera.transform.position.x, transform.position.y, playerCamera.transform.position.z); dist = Vector3.Distance(target, transform.position); // outputText.text = "Dist:" + dist.ToString(); if (dist >= 3.0f) { animator.SetBool("walking", true); animator.SetInteger("walknum", (int)Random.Range(0, 2)); guideState = TourGuideStates.FOLLOWING; } else if (dist <= 1.5f) { guideState = TourGuideStates.IDLE; animator.SetBool("walking", false); } }
void CheckState() { // heading toward an infopoint if (guideState == TourGuideStates.LEADING) { if (infoMarkerIndex != -1) { float stoppingDistance = 3.5f; float dist = Vector3.Distance(infoMarkers[infoMarkerIndex].gameObject.transform.position, transform.position); float distFromPlayer = Vector3.Distance(nearPlayer.position, transform.position); if (dist >= stoppingDistance) { animator.SetBool("walking", true); navMeshAgent.isStopped = false; if (distFromPlayer > 10) // keep the bot from moving too far away { navMeshAgent.isStopped = true; animator.SetBool("walking", false); } } else { guideState = TourGuideStates.IDLE; pointer.index = -1; // turns the pointer off navMeshAgent.isStopped = true; animator.SetBool("walking", false); TurnTowardCamera(); } } // if destination index is set } // if leading // heading toward the camera else if (guideState == TourGuideStates.FOLLOWING) { float dist = Vector3.Distance(nearPlayer.position, transform.position); if (dist >= 2.5f) { // TurnTowardCamera(); animator.SetBool("walking", true); navMeshAgent.isStopped = false; } else { guideState = TourGuideStates.IDLE; navMeshAgent.isStopped = true; animator.SetBool("walking", false); } } else if (guideState == TourGuideStates.IDLE) { float dist = Vector3.Distance(nearPlayer.position, transform.position); if (dist < 5) { navMeshAgent.isStopped = true; TurnTowardCamera(); } else { guideState = TourGuideStates.FOLLOWING; } } }