function to get gameobject from its id