From 8615b06f3b24aab9490af75f528a47802bd9c640 Mon Sep 17 00:00:00 2001 From: Martin Grider Date: Thu, 11 Jul 2024 10:51:00 -0500 Subject: [PATCH] make sure there are elements in the animation array before trying to access them. --- Sources/GateEngine/ECS/2D Specific/Sprite/SpriteComponent.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/GateEngine/ECS/2D Specific/Sprite/SpriteComponent.swift b/Sources/GateEngine/ECS/2D Specific/Sprite/SpriteComponent.swift index c867c395..de222be8 100644 --- a/Sources/GateEngine/ECS/2D Specific/Sprite/SpriteComponent.swift +++ b/Sources/GateEngine/ECS/2D Specific/Sprite/SpriteComponent.swift @@ -49,7 +49,7 @@ public final class SpriteComponent: Component { internal var moveToNextAnimationIfNeeded: Bool = false public var activeAnimation: SpriteAnimation? { get { - if let index = self.activeAnimationIndex { + if let index = self.activeAnimationIndex, self.animations.count > index { return self.animations[index] } return nil