Moving an object is a bit more complicated than that, especially if you want to keep it on the surface of the planet. To help, I created helper classes to move bodies taking into account their reference frame and position with regard to their parent. I also added a controller class which can be used to add behavior to objects in the engine.Finally I added basic plugin support, so in the yaml file you can link a controller to a body.
Here as an example the Curiosity rover making a loop on the procedural planet demo :
The controller code is quite simple :
from cosmonium.controllers import BodyController from cosmonium.astro import units from math import pi class TurnBody(BodyController): def update(self, time, dt): self.mover.turn_relative(pi / 100 / units.Sec * dt) self.mover.step_relative(0.001 / units.Sec * dt) ControllerClass = TurnBody
And in the curiosity yaml file I added the reference to the controller :
controller: name: turn file: modules/turn.py
(To be honest this is a bad example, the position is modified by delta so the errors will accumulate over time, especially if the simulation speed is increased. Instead one should keep a reference position and do updates relatives to it)
The new code is mostly there : https://github.com/cosmonium/cosmonium/blob/develop/cosmonium/controllers.py
There is also now a hidden feature, select the object, type ‘Control-T’ and a debug nav mode will be created to control the displacement of the body using the keyboard (The camera will be stuck in place, I still need to add proper follow camera mode and so on)