mncoder
Member
|
Creating a Dynamic CHR
I hope this hasn't been answered somewhere. I've looked all over.
I have been trying to dynamically create a Chr in Esenthel. I can see how they are placed in the world and then animated, but what if you want to spawn computer controlled entities from a point?
I have looked in Bloody Massacre and see how AIs are stored. I have looked at the "dynamically create an object" tutorial and can create static items. When I tried to merge these two and have a keypress create a Chr-like entity, nothing appears.
Are Items automatically drawn but Chr entities have to be updated on their own in the Game Update loop?
I was hoping adding the collection like this:
Game::ObjMemx< ComputerChr> AIs;
and then attaching to the world like this:
Game::World.init ( )
.setObjType(Players,OBJ_PLAYER)
.setObjType(Statics,OBJ_STATIC)
.setObjType(Items,OBJ_ITEM )
.setObjType(AIs, OBJ_CHR)
.New (ChrData.world()->worldDir());
would allow the new AIs to be added like this:
Game::World.objCreate(obj, obj.matrix);
Or does that just put the new object in the Items collection?
|
|
08-15-2011 09:08 PM |
|
Driklyn
Member
|
RE: Creating a Dynamic CHR
If obj.type() is set to OBJ_CHR, then it will create a new character.
EsenthelEngineSDK\Tutorials\Source\Advanced\4 - Demos, Game Basics\Game Basics\10 - Dynamically Created Objects.cpp
|
|
08-15-2011 11:10 PM |
|
mongots
Member
|
RE: Creating a Dynamic CHR
You should make sure the object that you are adding is of type OBJ_CHR as Driklyn said, you can check this out in the game editor.
Open the world editor and select the object tab, browse around to find the object your adding and you will see what object type it has set.
|
|
08-26-2011 04:11 PM |
|
red_evilspirit
Member
|
RE: Creating a Dynamic CHR
How can i creat a Dynamic CHR without using world editor ?
In the "10 - Dynamically Created Objects.cpp" tutorial, they use:
Game::ObjParamsPtr obj=Game::Objs.ptrRequire("obj/item/misc/barrel/0.obj");
I replaced like this:
Game::ObjParamsPtr obj=Game::Objs.ptrRequire("Obj/Chr/Skeleton/0.obj");
It didn't display any Skeleton.
-----------------------------------
It the same with "20 - Big Overlays.cpp" tutorial:
Game::ObjParams &bomb=*Game::Objs("obj/item/missile/bomb/0.obj");
I opened "custom params.world", but it don't have any Object Bomb.
-----------------------------------
So how can i place a charater into a world without using 'the world editor'
|
|
11-12-2011 07:47 AM |
|
kulesz
Member
|
RE: Creating a Dynamic CHR
Well, sooner or later you will need to use the world editor to create those *.obj files :-)
But you can set object type to OBJ_CHR from code - I don't remeber exactly (don't have the code right now), but there were some method like ObjType, SetObjType or something similiar :-)
EDIT:
Or maybe I have... Snippet from my code;
Code:
Game::ObjParamsPtr object = Game::Objs.ptrRequire("Data/Obj/chr/Player_male/0.obj");
object->type(true, "OBJ_PLAYER");
(This post was last modified: 11-12-2011 09:04 AM by kulesz.)
|
|
11-12-2011 09:02 AM |
|
red_evilspirit
Member
|
RE: Creating a Dynamic CHR
Thanks for your help but it didn't display anything when i press space button ("10 - Dynamically Created Objects.cpp" tutorial).
-------------------------
In tut: 20 - Big Overlays.cpp
When i press space button, it will display a bomb.
Can i do something like that with a charater ??
|
|
11-12-2011 11:58 AM |
|
kulesz
Member
|
RE: Creating a Dynamic CHR
Did you make an character container and correctly used the setObjType when initializing the world?
|
|
11-12-2011 12:02 PM |
|
red_evilspirit
Member
|
|
11-12-2011 01:43 PM |
|
kulesz
Member
|
RE: Creating a Dynamic CHR
What error?
There should be <Game::Chr>, not the <Char>
|
|
11-12-2011 02:58 PM |
|
red_evilspirit
Member
|
RE: Creating a Dynamic CHR
(11-12-2011 02:58 PM)kulesz Wrote: There should be <Game::Chr>, not the <Char>
Oh, i forgot that >.<
Thank you so much!
|
|
11-12-2011 03:41 PM |
|