architecture – Instantiating GameObjects in Custom Game Engine


So,i’m having a bit of an issue with instantiating my gameobjects into to universe(My Scene object).

I can create an empty object from scratch and populate it from there with ease,my problem starts when i try to clone the gameobject which i just created.

My steps are

  1. I create an empty gameobject (GAMEOBJECT A)
  2. I add an component to it (COMPONENT A)
  3. Now i create a gameobject B from A
  4. GameObject B created,and the component A is in the component list of the gameobject B
  5. I try to get the component using inheritance but nullptr returns

It seems when i try to clone components,it returns only the base class pointer.There i try to recreate the derived class and add it to new gameobject’s component list but obviously i fail.

  • If i cant solve this with inheritance how can i solve it ?
  • is there better way to implement such a desing ?
  • or i just fail to use inheritance in c++.If it’s, can you guys point out what am i doing wrong here

This is my GameObject AKA RGameElement

enter image description here

This is my Component AKA RElementComponent

enter image description here

and this my Instantiate via gameobject ref function

enter image description here