protected virtual void Start() { enemyPhysics = transform.parent; animator = GetComponent <Animator>(); enemyStatus = GetComponent <EnemyStatus>(); spriteRenderer = GetComponent <SpriteRenderer>(); enemyMovement = enemyPhysics.GetComponent <EnemyMovement>(); controller = enemyPhysics.GetComponent <Controller2D>(); currentState = State.Idle; transitionState = State.Idle; temporaryState = State.None; none = State.None; idle = State.Idle; patrol = State.Patrol; chase = State.Chase; attack = State.Attack; interact = State.Interact; hurt = State.Hurt; die = State.Die; SetAnimTimeDictionary(); CachingAnimation(); }
void Start() { gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2); maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight); controller = GetComponent <Controller2D>(); direction = new Vector2(0, 0); CurrentHp = Hp; playerPos = GameObject.FindGameObjectWithTag("Player"); boxCollider = GetComponent <BoxCollider2D>(); enemyStatus = transform.GetChild(0).GetComponent <EnemyStatus>(); SetCrushedArea(); coroutineCycle = 0.1f; waitTime = new WaitForSeconds(coroutineCycle); StartCoroutine(CheckCrushed()); }