About Store Forum Documentation Contact



Post Reply 
Custom object types
Author Message
Kiekos Offline
Member

Post: #1
Custom object types
I'm currently just messing around with custom object types and I've tried to create OBJ_NPC. Unfortunately it didn't go as I expected.

One of the characters placed on the world has this type set up. In "main.h" I declared "struct NPC" and included "NPC.h". I defined the structure in "NPC.h" and also created "NPC.cpp" file. This was done as well:

Code:
Game::ObjMemx<NPC> NPCs;
Game::World.setObjType (NPCs, OBJ_NPC);

My question is what has to be defined in the structure in order for the object to be drawn, as right now nothing happens. I've tried copying parts from player's structure:

Code:
STRUCT(NPC , Game::Chr)
//{
   Bool update();
   UInt drawPrepare();
   void drawShadow();
  
   NPC();
};

... but as you may have already figured out, it didn't help. Does anyone know what am I doing wrong?
(This post was last modified: 06-13-2013 05:56 PM by Kiekos.)
06-13-2013 05:15 PM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #2
RE: Custom object types
I'd recommend you take a careful look at Scarlet Threads video on Game Objects here
06-13-2013 05:31 PM
Find all posts by this user Quote this message in a reply
Kiekos Offline
Member

Post: #3
RE: Custom object types
Well, I've tried to follow them.

I was missing the create function so I added it and still nothing. I just want the NPC to be drawn - no custom parameters, no other features, just drawing. I'm so confused right now... :s
06-13-2013 06:25 PM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #4
RE: Custom object types
Well if you are not adding any custom features at this stage you only need to base the new object on the chr object as it already has all the functionality to do display itself.

If you override functions you need to provide code for those functions and possibly call the base functions if you want to include their functionality. In other words ... don't override base class functions unless you intend extending or changing their functionality.
06-13-2013 07:34 PM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #5
RE: Custom object types
An example:

Given you defined the object container and setObjectType as shown in your code above, you have created an object called OBJ_NPC, you have a character model imported and have assigned it the object type OBJ_NPC, then the following is the bare minimum required to create the class and have your character drawn in the level

Code:
struct NPC : Game::Chr
{
  
};

This is your basic starting point. You can then start to override base class procedures to extend or alter the functionality and if need be add and call procedures of your own.
06-13-2013 10:50 PM
Find all posts by this user Quote this message in a reply
Kiekos Offline
Member

Post: #6
RE: Custom object types
Thanks for the explanation, however it's still not drawing the npc, even if I just define an empty structure like you did above without overriding any functions.

This is what the object specs look in the world editor:
[Image: 41nzdp.jpg]

I can't see anything that could be wrong here... I have defined the container and set its ObjectType. What am I missing?
06-14-2013 10:04 AM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #7
RE: Custom object types
I am not entirely sure what it is you are attempting to do here, as I have no idea of why you are wanting to customize the Character object or any details of the model.

However, just looking at the screen shot you've posted above, there doesn't appear to be any physics body associated with the model (which the character class requires) although I don't actually recognize this screen ... are you working with Version 1.0 of Esenthel?

Basically, you should be able to set the type to OBJ_CHR and have that display your model in the level. If this doesn't work, basing any class on the Character class will not work either.

If you intend extending or altering the Character class you need to understand its functionality and prerequisites first! You need to know what you are dealing with before you can realistically change it.

You really need the Game Object code, which I think only comes with the licensed software, and study Character.cpp before attempting to base objects on it.

I'm sorry if I'm pointing out things you already know, but I don't know your background and coding ability.
06-14-2013 01:51 PM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #8
RE: Custom object types
Show implementation of :
Bool update();
UInt drawPrepare();
void drawShadow();
06-14-2013 02:31 PM
Find all posts by this user Quote this message in a reply
Kiekos Offline
Member

Post: #9
RE: Custom object types
Right now I left the structure empty as Pixel suggested. It should inherit the functions from Game::Chr but it doesn't seem to.

The whole thing looks like this now:

Code:
//Main.h

struct NPC;
include "NPC.h";
Code:
//NPC.h

STRUCT (NPC , Game::Chr)
//{
};
Code:
Game::ObjMemx<NPC> NPCs;
Game::World.setObjType (NPCs, OBJ_NPC);

There is an object placed on the world with it's type set to OBJ_NPC which is not being drawn with this configuration of the structure. I'm out of ideas.



I start to think there might be a different problem cause I did this a second ago:
Code:
Game::ObjMemx<Game::Chr> NPCs;
and it still doesn't draw the NPC which should be drawn...
06-14-2013 08:39 PM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #10
RE: Custom object types
Place default character object and change type to NPC.
06-14-2013 09:05 PM
Find all posts by this user Quote this message in a reply
Post Reply