protected virtual void SnapSpriteToGrid() { Sprite.GlobalPosition = GlobalPosition.DistanceTo(Sprite.GlobalPosition) > 0.7 ? GlobalPosition.Round() : Sprite.GlobalPosition.Round(); DeathSprite.GlobalPosition = GlobalPosition.Round(); }
private void StateSettled() { if (_stateMachine.IsStateNew()) { CollisionLayer = 0; CollisionMask = 0; _velocity = Vector2.Zero; GlobalPosition = GlobalPosition.Round(); _animationPlayer.Play(ANIM_IDLE); _collisionShape2d.Disabled = true; _deathTimer.Start(); } var playerPosition = GetTree().GetFirstNodeInGroup <Player>(Player.GROUP)?.GlobalPosition ?? Vector2.Zero; var near = GlobalPosition.DistanceSquaredTo(playerPosition) < PLAYER_NEAR_DISTANCE * PLAYER_NEAR_DISTANCE; if (!_deathTimer.IsStopped() && near) { _deathTimer.Start(); } else if (near && _blinkAnimationPlayer.IsPlaying()) { ResetBlink(); _deathTimer.Start(); } }
public override void _PhysicsProcess(float delta) { Camera2D.GlobalPosition = GlobalPosition.Round(); CheckForTransitions(); }
protected override void SnapSpriteToGrid() { base.SnapSpriteToGrid(); Gravestone.GlobalPosition = GlobalPosition.Round(); }