I’ve put together my own RK45 based n-body gravity field solver in C++ and have a pretty basic visualization setup in Ogre3D to test it out. I’ve been wanting to use that gravity field solver as a starting point for a semi-realistic spaceflight game, my own rigid body dynamics class or some engineering visualization sims. Was excited to see UE4 go “free” and thought this was a good opportunity to get my projects going in a very well supported, mainstream engine.
Just curious if anyone could point me in the right direction on a problem I’ve run into. I think it’s pretty fundamental.
Been looking through tutorials and wiki’s for a month or so now. Basic UE4 blueprint and C++/UE4 C++ is no problems and I think I understand most of the example applications shown.
The problem I have is that I just can’t figure out how to bridge the gap between my generic n-body solver class and the UE4 actor world space. It was easy at a low-level with just basic OpenGL or even Ogre3D. I think the problem I want to solve is applicable to any environment-wide physics effect I would want in UE4 where a certain set of actors to respond to each other in a certain way based on the output from another actor that is monitoring their properties. I think I am missing some fundamental UE4 concepts just beyond the basic examples, or missed something in the basic examples :).
What is the proper way to “register” an actor class with the solver class? I’d imagine i’d just instantiate the solver as another actor to get it into the game world space, but not sure how to go from there.
How do I tick the solver within the UE4 physics frames so that the latest position and velocity solutions, or even look-ahead results are available during all actor rendering tick cycles?
In my generic C++ test setup I just setup a STD vector and push in “gravity field” objects i’ve defined and then iterate the sover from some initial position state. I can add in forces from user controls or predefined arrays easily. For visualization in Ogre3D I have a simple game-loop that iterates as many n-body solver cycles in between each render cycle. Then I just sync the graphics coordinate space to physics for the render cycle to display at the fastest frame-rate possible.
- Might be a tie-in to question #2, but is there a good UE4 friendly way to optimize this type of actor to actor interaction? I don’t want my custom physics to be a burden to the rest of the engine.
At a high-level, I would want to be able to add a property to the basic actor class that toggles between the n-body solver and the z-axis normal gravity which UE4 physics uses out of the box. For now, I plan on using the rigid-body physics that comes with the engine, at least until I create a soft-body model for more realistic material deformations and figure out how to get that into UE4 as well. Looking into different real-time CFD methods for calculating aerodynamic forces as well.
I’ll keep looking through the forums and examples to see if I can get a clue. Thanks for anything anyone can show me and I appreciate the time you’ve taken to read this.