Best way to reference every object in each game loop

I’ve started building a game which uses planetary physics, which means I can’t use the default box2d gravity - I need to do the simulation of gravity and application of forces myself.

This means something like:

for each physics_affected_gameobject: determine force to apply from each planet apply calculated total force to gameobject

Is the message passing setup really the best way to do this, or should I be hacking into the physics engine hooks, or using some other mechanism?

I guess my question is “What’s the most efficient way to get properties of every game object at every time step?”

Thanks!

Using message passing to get and set properties is not efficient and not how it is intended to be used. I would suggest that you keep all physics data where the physics is calculated and use game objects for visual representation.

1 Like