About Store Forum Documentation Contact



Post Reply 
Object create class override
Author Message
AndrewBGS Offline
Member

Post: #1
Object create class override
I'd like to know if it is possible to create dynamically in the game world an object that doesn't belong to the class the Game.ObjParamsPtr points to.

Example:
I have a skeleton, I drag & drop the model in the world. The skeleton is an OBJ_CHR. In world, I set that particular skeleton to be OBJ_PLAYER. Now my question is, in the player class who's create will be automatically called, can I call a create function from Character such that the skeleton will be created as a Character, not a player? (this is an example, it's not what I actually want to do; I just want to know if it is possible, not get a workaround).

Here's how I immagine the code:

Player:
void create(Game.ObjParams &obj){

(Character) Game.World.ObjCreate(obj, ....);
}

//yes I know in this case just super would do the trick. but assume player doesn't extend character. Can I somehow force the created object to belong to another class than what it's set to in world editor?

I hope I'm clear enough, sorry I wrote so much.

P.S.: Something that might help me implement a factory pattern.
(This post was last modified: 11-17-2013 09:58 AM by AndrewBGS.)
11-17-2013 09:40 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Object create class override
Game.ObjParams obj;
obj.base(set skeleton);
obj.type(true, set custom object class);
Game.World.objCreate(obj);
11-17-2013 09:45 PM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #3
RE: Object create class override
That's lovely; but I get a run-time crash;
Does it matter that I try to create a OBJ_CHR with more parameters than the Character needs? (the base should be the obj itself)

Let me detail how I'm doing this:

1) I drag&drop the skeleton character in the world. It belongs to OBJ_CHR Character class.
2) In world editor I override it to belong to my Factory class, adding few more parameters to it
3) In the Factory class code, I want to create a Character object using its own objParamsPtr (which should contain all the skeleton's info already).

What you said is precisely what I'm looking for, but it seems to crash for reasons I can't understand.
11-17-2013 10:25 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Object create class override
Did you try to do debugging and view the callstack?
11-17-2013 10:59 PM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #5
RE: Object create class override
ntdll.dll!770815ee() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!770815ee() Unknown
ntdll.dll!7707015e() Unknown
PhysX3_x86.dll!523fd7b6() Unknown
Spawner.exe!EE::Game::Obj::updateArea(void) C++
Spawner.exe!EE::Game::WorldManager::objCreate(struct EE::Game::ObjParams &,struct EE::Matrix const &,struct EE::UID const *) C++
> Spawner.exe!Spawner::update() Line 39 C++
Spawner.exe!EE::Game::WorldManager::updateObjects(void) C++


This is the call stack, but I'm afraid I'm not experienced enough to understand much of it. I'd appreciate if someone could enlighten me and tell me what I should gather from this.
11-17-2013 11:17 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Object create class override
PhysX is mentioned, so it looks like it's physics related, check if your object actor is properly created.
11-18-2013 07:14 AM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #7
RE: Object create class override
I'm at work now, don't have the project here, but I am using the skeleton object provided on the website. It works properly, if I use it as a character (without overriding it) it works lovely. If I try to create it without setting object.type, it does nothing (probably creates him as another factory object) but it doesn't crash.

Combining that object type cast to OBJ_CHR and then creating it, that crashes it.

not sure what I should do with object base; As far as I can tell, the base is already the skeleton, the object itself - although it now has a few extra factory parameters - so I didn't change anything for the base. Maybe I'm missing something there.
(This post was last modified: 11-18-2013 07:54 AM by AndrewBGS.)
11-18-2013 07:52 AM
Find all posts by this user Quote this message in a reply
Post Reply