With Chaos Modular Vehicles, is it possible to reset the simulation for a vehicle without removing the vehicle? Or, is it possible to update a module’s setup during gameplay?
I am working on a racing game and would like to implement a pitstop system using C++. Looking at the API, I can’t see an easy or efficient way to do this with the current framework.
I have attempted this in both the game thread and the physics thread. In the game thread, using the VehicleSimBaseComponent and applying UpdatePhysicalProperties(). In the Physics thread, I passed a new input type in the AsyncInput that read the data and applied it to the correct module. The value changed worked but there was no clear way to reset the simulation.
Which approach is the correct one, and is this even possible?
Thanks
Turns out, this is not possible with the current frame work and my first approach was incorrect. It is possible by extending the framework to include things that are missing with this experimental framework.
Since vehicle systems are contained in the systems tree, by modifying the container to handle updates along with adds and removals, updates would be sent from the game thread to the physics thread using the cluster union component.
First, I started with a new function on the simulation component, sent from the pawn after inputs are not allowed. The new function gathers a list of what has changed, then creates a new module using the corresponding scene component and modifies the setup. It also updates the container by appending action updates to the cluster union component.
These updates are added from the game thread and processed on the physics thread. Once the update of the module is completed. The module meta information (type, guid, tree index) is sent back to the game thread, to the simulation component, using asyncOutput. The simulation component processes the info in the PostUpdate() and then broadcasts an update event that can be observed by the pawn, allowing the player to regain control with the newly updated setup.