private void Awake() { rightSensor.enabled = false; leftSensor.enabled = false; audioPlayer = GetComponent <AudioSource>(); rigid = GetComponent <Rigidbody>(); waypointNavigator = GetComponent <WaypointNavigator>(); showStopSignals(false); updateSignalsStatus(true); }
void setupNavigator(WaypointNavigator navigator, WaypointData waypoint) { if (waypoint == null) { return; } // make sure this waypoint isn't reused for spawning more entities waypoint.occupied = true; Vector3 spawnPosition = waypoint.centerPosition; spawnPosition.y += 0.5f; navigator.gameObject.transform.position = spawnPosition; // Point spawned entities looking at their next waypoint Vector3 lookPos = spawnPosition; if (waypoint.nextWaypoint != null) { lookPos = waypoint.nextWaypoint.centerPosition; } else if (waypoint.previousWaypoint != null) { lookPos = waypoint.previousWaypoint.centerPosition; } lookPos.y = navigator.gameObject.transform.position.y; navigator.gameObject.transform.LookAt(lookPos); int direction; if (allowedDirection == Direction.Both) { direction = Mathf.RoundToInt(Random.Range(0f, 1f)); } else { direction = (int)allowedDirection; } navigator.init(direction, waypoint); }
private void Awake() { animator = GetComponent <Animator>(); waypointNavigator = GetComponent <WaypointNavigator>(); }