GameObject Tweening: Prove of concept using Native Arrays.

For any one who may be interested in topic. (Just the prove of concept)

So I was thinking recently, how I could approach tweening solutions, between GameObjects and ECS.
I have seen posts for example
__ ECS-Tween: A very simple tweening system using ECS that works with GameObjects __
as well as Hybrid demos.

But I wasn’t convinced, is a good solution for my application. Hence I decided to work on mine.

The concept is, that I only utilize RigidBodies and Colliders of the Classic OOP Physics, while rendering part, is done on ECS side using entities.

The way how I approached it, is by using NativeArrays as medium, between two realms.
So firstly at creation of block entities, I generate basics data, for which, first entity is related to RigidBody, the other entities store relative position and rotation to the RigidBody.
Then I generate in Classic OOP dictionary, which matches entity index, to the GameObject.

  • OOP side has form of listener, which waits for commands, stored in native arrays. Is basically if condition, in FixedUpdate, checking if the command count is greater than 0. I never dispose arrays.
  • OOP also has one updater method, which sends every FixedUpdate position and rotation of the RigidBody (only), if requested from ECS. Same principle on arrays.
  • ECS side listens to changes in native array, and executes rendering of cubes, calculating relative offset etc.

That way, I can send for example command, for adding force. Or adding more blocks etc.

The main reason I didn’t want to use default approach, using Game Object Entity Component, as I do expect have many rendering objects. But not necessary need as many colliders. So I can store in pool as spare, to reuse when needed.

Is hard to say regarding performance. I hope for good. But I will yet need to do stress testing.

But either way I wanted prove the concept that decoupling two worlds can be done, using merely Native Arrays.

If have any thought, please drop in.

5 Likes

So here I expanded it, and added my modding tool, using Shunting Yard techniques.
Discussed a bit more here.
** Ordering math equation from pseudo code. **

Multi threading now is supported and burst.

2 Likes