viewer.flyTo doesn't work

I have an entity that I know for sure is valid and is an entity. When I put this entity into viewer.flyTo(entity) it returns a promise but *does not move the camera*.

This entity can be put into "viewer.selectedEntity" function and it works just fine. So I know the entity is valid. Is there something I'm missing?

This is how I find the entity I'm passing to the function:

function findEntity(mmsi) {
    var entity = null;
    \(viewer\.dataSources\.\_dataSources\)\.each\(function \(i, o\) \{         if \(o\.\_name == 'shipsKML'\) \{ //search inside shipsKML             (o._entityCollection._entities._array).each(function (_i, _o) {
                if (_o._id = mmsi) {
                    entity = _o; return false;
                }
            })
        }
    });
    viewer.flyTo(entity) //DOESN'T WORK
}

Hello,

I’m not sure exactly what is going on, but this looks like a scoping issue to me. Try calling viewer.flyTo from inside your function instead of setting the entity variable.

Best,

Hannah