# Cannot read property "frame" of undefined at Animation.ts:831

**URL:** <https://forum.babylonjs.com/t/cannot-read-property-frame-of-undefined-at-animation-ts-831/21925>\
**Category:** Bugs\
**Created:** [June 27, 2021, 8:41pm UTC](https://forum.babylonjs.com/t/cannot-read-property-frame-of-undefined-at-animation-ts-831/21925 "2021-06-27T20:41:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antidamage](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/antidamage/32/19857_2.png) [@Antidamage](https://forum.babylonjs.com/u/Antidamage)\
**Post date:** [June 27, 2021, 8:41pm UTC](https://forum.babylonjs.com/t/cannot-read-property-frame-of-undefined-at-animation-ts-831/21925/1 "2021-06-27T20:41:36Z")

</div>

I’m trying to figure out how this could possibly work:

```auto
        for (var key = startKeyIndex; key < keys.length; key++) {
            var endKey = keys[key + 1];

            if (endKey.frame >= currentFrame) { <<<<<<<<<<<<<<<<<<<
                state.key = key;
                var startKey = keys[key];
                var startValue = this._getKeyValue(startKey.value);
                if (startKey.interpolation === AnimationKeyInterpolation.STEP) {
                    return startValue;
                }

```

This seems like key + 1 will always go out of bounds. Changing the statement to “keys \< keys.length - 1” definitely improves it.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 27, 2021, 9:11pm UTC](https://forum.babylonjs.com/t/cannot-read-property-frame-of-undefined-at-animation-ts-831/21925/2 "2021-06-27T21:11:43Z")

</div>

This has been fixed 4 months ago: [Woot! found a bug in animation engine ;) · BabylonJS/Babylon.js@742be17 · GitHub](https://github.com/BabylonJS/Babylon.js/commit/742be1779faf2a42f02a3c396e03ac88e3107182#diff-ab53590e10b72bd85c7935bba9abdb5c340e13d264e9427e70f27a1776870941R828)

Thanks a ton for reporting it by the way 🙂

---

<div class="post-metadata">

**Author:** ![Antidamage](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/antidamage/32/19857_2.png) [@Antidamage](https://forum.babylonjs.com/u/Antidamage)\
**Post date:** [June 27, 2021, 9:23pm UTC](https://forum.babylonjs.com/t/cannot-read-property-frame-of-undefined-at-animation-ts-831/21925/3 "2021-06-27T21:23:03Z")

</div>

Oh, we’re just out of date? Cool. 🙂
