About Store Forum Documentation Contact
Donations:
289$/mo



Post Reply 
Creating dynamically characters
Author Message
Fritz Offline
Member

Post: #1
Creating dynamically characters
How can I create characters in game?

I've tried this, but it doesn't work.

Code:
Game::ObjParams param;
    param.mesh(true,Meshes.ptr("obj/chr/warrior/body.mesh"));
    param.skeleton(true,Skeletons("obj/chr/warrior/body.skel"));
    param.matrix.setScalePos(5,Vec(0,0,0));
    param.type(true, "OBJ_PLAYER");

    bool res= Game::World.objCreate(param,param.matrix);
res is always false :(


I also tried to use the draw function manually, but a pyramid is drawn:

unit = new Game::Chr();
unit.create(param);

Creating the object in the world editor works fine.
03-29-2011 09:17 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Creating dynamically characters
check if you have object container for OBJ_PLAYER

you must have some issue somewhere, please check the "dynamically creating objects" tutorial

Edit: this will fail only if you haven't set the player object container for the enum
03-30-2011 10:53 AM
Find all posts by this user Quote this message in a reply
Fritz Offline
Member

Post: #3
RE: Creating dynamically characters
I didn't include the enums, now it works. Thanks!

Still I have a question. Is there a way to get the index of the created character?
I could call the last element of container, but is there a different possibility to get the index?
03-30-2011 05:40 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #4
RE: Creating dynamically characters
Another way i can think of is to check how many elements there are in the container with players.elms()

or

PHP Code:
Int  index   (TYPE *elm)C
Bool contains(TYPE *elm)C

There is always evil somewhere, you just have to look for it properly.
(This post was last modified: 03-30-2011 06:59 PM by Dynad.)
03-30-2011 06:28 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply