Page 1 of 1

c# cryengine 5.3 Maze generator

Posted: Wed Jul 26, 2017 12:38 pm
by goloox
HI, could someone make help or make tutorial for how to create a maze generator. i followed this tutorial https://www.cryengine.com/community_arc ... 4#p1305474, but it seem that in 5.3 entity Instantiate has changed and there is no documentation about it ( at least i couldn't find). so if someone could point me in right direction i would appreciate it. It doesn't necessarily need to be in c# if someone knows how to make it in flowgraph or schematycs that is also fine.

Thanks.

Re: c# cryengine 5.3 Maze generator

Posted: Wed Jul 26, 2017 12:50 pm
by cry-miron
To instantiate an Entity you can use Entity.SpawnWithComponent(). Keep in mind that you have to specify a component that gets added to the component as well. You could for example make a MazeBlock EntityComponent that automatically loads the "objects/default/mtlbox.cgf" geometry on its Entity.

Re: c# cryengine 5.3 Maze generator

Posted: Fri Jul 28, 2017 6:00 pm
by goloox
Hi,

I tried the solution you posted but i cant get the objects to load. here is my code:

Code: Select all

[EntityClass] public class MazeBlock : EntityComponent { private string _GeometryUrl = "Objects/Default/primitive_sphere.cgf"; [EntityProperty(EntityPropertyType.Object, "Path where the geometry-file is located.")] public string GeometryUrl { get { return _GeometryUrl; } set { _GeometryUrl = value; //Initialize again so the geometry is reloaded. Initialize(); } } private void Initialize() { Entity.LoadGeometry(0, _GeometryUrl); } } ---------------------------------------------------------------------------- void OnKey(SInputEvent e) { if (e.KeyPressed(EKeyId.eKI_F6)) { MazeBlock mazblock = new MazeBlock(); position = new Vector3(40, 40, 40); Entity.SpawnWithComponent<MazeBlock>(position, Quat.CreateIdentity(), 3f); } }

Re: c# cryengine 5.3 Maze generator

Posted: Fri Jul 28, 2017 7:03 pm
by cry-miron
You don't need to instantiate EntityComponents with new. The following OnKey method should work:

Code: Select all

void OnKey(SInputEvent e) { if (e.KeyPressed(EKeyId.eKI_F6)) { var position = new Vector3(40, 40, 40); MazeBlock mazblock = Entity.SpawnWithComponent<MazeBlock>(position, Quat.CreateIdentity(), 3f); } }

Re: c# cryengine 5.3 Maze generator

Posted: Fri Jul 28, 2017 7:58 pm
by goloox
Thanks for fast reply. it didnt quite work the first time i tried, but i found the problem why it wasnt loading. i needed to change my EntityClass to this adding the constructor:

Code: Select all

[EntityClass] public class MazeBlock : EntityComponent { private string _GeometryUrl = "Objects/Default/primitive_sphere.cgf"; [EntityProperty(EntityPropertyType.Object, "Path where the player's geometry-file is located.")] public string GeometryUrl { get { return _GeometryUrl; } set { _GeometryUrl = value; //Initialize again so the geometry is reloaded. } } public MazeBlock() { var entity = Entity; // Load the third person model entity.LoadGeometry(0, _GeometryUrl); } } }