Programatically creating entities
Posted: Mon Dec 02, 2013 6:09 pm
Hi,
I want to add entities to my arena at some point in the program. As far as I understand, you have to use CFactory::New to do this, instead of just creating the entities yourself. So what I am trying is:
However, the cast throws an error. I also tried just adding the pelletEntity itself, commenting out the 3 lines of code in the middle, but that thew segmentation error. Could somebody please explain how you can add boxes (and set their properties) properly?
I want to add entities to my arena at some point in the program. As far as I understand, you have to use CFactory::New to do this, instead of just creating the entities yourself. So what I am trying is:
Code: Select all
CEntity pelletEntity = *CFactory<CEntity>::New("box");
CBoxEntity& pellet = *any_cast<CBoxEntity*>(pelletEntity);
pellet.SetSize(CVector3(1,1,1));
pellet.SetMass(1);
AddEntity(pelletEntity);