Mob.cs 432 B

1234567891011121314151617
  1. using Godot;
  2. public partial class Mob : RigidDynamicBody2D
  3. {
  4. public override void _Ready()
  5. {
  6. var animSprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
  7. animSprite.Playing = true;
  8. string[] mobTypes = animSprite.Frames.GetAnimationNames();
  9. animSprite.Animation = mobTypes[GD.Randi() % mobTypes.Length];
  10. }
  11. public void OnVisibilityScreenExited()
  12. {
  13. QueueFree();
  14. }
  15. }