// Start is called before the first frame update void Start() { curpointidx = 0; lastpointidx = waypoints.Count - 1; //Assuming that count is the size of the list rb = GetComponent<Rigidbody2D>(); alerted = false; wasAlerted = false; lookingAround = false; playingFoundMusic = false; playingStealthMusic = true; playerPosition = Vector2.zero; speed = patrolSpeed; detectScript = GetComponent<RayEnemyDetect>(); stealthMusic = audioStealth.gameObject.GetComponent<AudioSource>(); foundMusicOne = audioFoundOne.gameObject.GetComponent<AudioSource>(); foundMusicTwo = audioFoundTwo.gameObject.GetComponent<AudioSource>(); // Safety check to make sure nothing is null, if something is then destroy gameobject foreach (var point in waypoints) { if (point == null) { Destroy(gameObject); print("WAYPOINT BOI HAS NULL WAYPOINT FOR SOME REASON: DESTROYING"); throw new MissingReferenceException(); } if (point.position.z != 0) point.position = new Vector3(point.position.x, point.position.y, 0); } }
void Start() { red = gameObject.GetComponent <RayEnemyDetect>(); rb = gameObject.GetComponent <Rigidbody2D>(); }