public override void StateUpdate() { RaycastHit2D groundProbe = _ground.GroundProbe; // MOVE Vector2 direction = _input.Direction.x * Fsm.transform.right; Fsm.transform.up = groundProbe.normal; _locomotion.Move(direction); // X SCALE INVERSION Vector3 scale = Fsm.transform.localScale; if ((direction.x < 0f && scale.x > 0f) || (direction.x > 0f && scale.x < 0f)) { scale.x *= -1; } Fsm.transform.localScale = scale; // GROUND HUGGING /!\ bug : se colle au plafond et aux murs quasi-verticaux, se clipse trop tôt aux pentes Collider2D col = Fsm.GetComponent <Collider2D>(); if (_ground.IsCloseToGround && _input.Direction != Vector2.zero) { Fsm.transform.position = groundProbe.point + (col.bounds.extents.y * groundProbe.normal); } }
void Update() { _locomotion.Move(transform.right); gameObject.DestroyIfOutOfScreen(0.3f); if (_collision.IsColliding && (!_collision.HasOtherACollisionManager || _collision.IsOtherInDifferentTeam)) { DestroyProjectile(); } }
public override void StateUpdate() { // MOVE Vector2 direction = _input.Direction; direction.y = 0; _locomotion.Move(direction); // X SCALE INVERSION Vector3 scale = Fsm.transform.localScale; if ((direction.x < 0f && scale.x > 0f) || (direction.x > 0f && scale.x < 0f)) { scale.x *= -1; } Fsm.transform.localScale = scale; }
public override void StateEnter() { _locomotion.Move(Vector2.up, _locomotion.JumpForce, true); }
public override void StateEnter() { _health.Value -= _collision.LastCollidedObject.GetComponent <ManagerCollision>().Damages; _knockbackDirection = (Fsm.transform.position - _collision.LastCollidedObject.position).normalized.x * Vector2.right + 3 * Vector2.up; // -_locomotion.LastDirection; _locomotion.Move(_knockbackDirection, _knockbackSpeed); }