void OnStateChange(States before, States after) { if ((before & States.Ladder) == States.Ladder && (after & States.OnGround) == States.OnGround) { aiInput.SetY(0); aiInput.SetX((float)facing); } }
public override void OnAwake(bool notify = true) { base.OnAwake(notify); aiInput = instance.GetComponentInChildren <AIInput>(); if (aiInput == null) { Debug.LogWarning("AIInput is expected in the prefab"); return; } pc2d = instance.GetComponentInChildren <PlatformerCollider2D>(); character = instance.GetComponentInChildren <Character>(); aiInput.SetX(1); character.onAreaChange += OnAreaChange; character.onStateChange += OnStateChange; pc2d.onLeftWall += OnLeftWall; pc2d.onRightWall += OnRightWall; }