void Start() { //Components rb = gameObject.GetComponent <Rigidbody>(); rb.constraints = RigidbodyConstraints.FreezeRotation; path = gameObject.AddComponent <Pathfinding>(); player = GameObject.FindWithTag("Player").GetComponent <PlayerBehaviour>(); anim = gameObject.GetComponent <EnemyAnimationScript>(); anim.Play("idle"); if (!canFindPathPlayer()) { Destroy(gameObject); } hs = gameObject.AddComponent <HealthScript>(); hs.damage(-health); //Settings //Variables dead = false; can_move = true; lock_on = false; velocity = Vector2.zero; path_index = 0; path_array = null; target_position = new Vector2(transform.position.x, transform.position.z); play_sound = false; }
void Start() { float sleepTime = Random.Range(sleepTimeRange.x, sleepTimeRange.y); zPosition = transform.position.z; Invoke("WakeUp", sleepTime); enemyAnimation = GetComponent<EnemyAnimationScript>(); enemyAnimation.setSleepTime (sleepTime); enemyAnimation.setEnemyAnimation (EnemyAnimationScript.EnemyAnimation.wakeAnimation); startRadius = sleepingRadius; // startAngle = Random.Range(0f, 360f); startAngle = -359f; Quaternion degrees = Quaternion.Euler(0, 0, startAngle); Vector3 unrotatedStart = new Vector3(sleepingRadius, 0, zPosition); transform.position = degrees * unrotatedStart; float rectLeft = huntingRadius - attackRange; watchingRect = new Rect(rectLeft, attackWidth/2, attackRange, attackWidth); // attackInterval = attackGapTime; //get animation script }