About Store Forum Documentation Contact
Donations:
140$/mo



Post Reply 
Inserting character in world
Author Message
Dwight Offline
Silver Supporter

Post: #1
Inserting character in world
Hi all,

Back in the day, this used to work to insert a character into the world:

Code:
void create(Int ID, Str name, Vec2 position, Flt scale)
{
    Game::ObjParams obj;

    obj.create(*Game::Objs(UID(xx, xx, xx, xx)));
    obj.scale (true, scale);

    obj.matrix.pos.x = position.x;
    obj.matrix.pos.z = position.y;
    obj.matrix.pos.y = Game::World.hmHeight(position);  

    UID uid;
    uid.fromText(L"OBJ_CHR");

    obj.type(true, uid);

    super::create(obj);

    Name    = name;
    this->ID = ID;

    ctrl.actor.mass(1).kinematic(true).collision(true).group(ACTOR_NPC).obj(thi​s);
}

This is what my old code has to insert a character into the world (server sided AI). I have issues finding the equivalent of "Game::ObjParams" [I thought it was ObjectPtr?].

How can I insert a character, like the example above, in the world through code?
04-16-2021 01:33 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: Inserting character in world
I've personally done something like

Code:
Object al = *ObjectPtr(UID(1271515657, 1092039634, 723414949, 1137966898));
    al.type(true, UID(2374035910, 1193790438, 2299804040, 3325652051));
    Game::World.objCreateNear(al, Matrix(1.7,actor.box().center()));

when I wanted to dynamically change something without messing around with the stored ObjectPtr cache.

not sure if this still works in latest versions, but seeing the tutorial still uses ObjectPtr it would seem it should.
(This post was last modified: 04-17-2021 07:08 AM by Zervox.)
04-17-2021 07:08 AM
Find all posts by this user Quote this message in a reply
Dwight Offline
Silver Supporter

Post: #3
RE: Inserting character in world
Hi Zervox,

Thanks for the information! I should now just debug why spawning that NPC makes my client crash, but it's progress! grin

Good to see you lurking and posting here sometimes!
04-17-2021 05:15 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #4
RE: Inserting character in world
(04-17-2021 05:15 PM)Dwight Wrote:  Hi Zervox,

Thanks for the information! I should now just debug why spawning that NPC makes my client crash, but it's progress! grin

Good to see you lurking and posting here sometimes!

I regularly lurk around, just very little time to actual post or do development with the engine, but still keeping track of updates and posts, life and all that. smile
04-18-2021 07:52 AM
Find all posts by this user Quote this message in a reply
Dwight Offline
Silver Supporter

Post: #5
RE: Inserting character in world
(04-18-2021 07:52 AM)Zervox Wrote:  
(04-17-2021 05:15 PM)Dwight Wrote:  Hi Zervox,

Thanks for the information! I should now just debug why spawning that NPC makes my client crash, but it's progress! grin

Good to see you lurking and posting here sometimes!

I regularly lurk around, just very little time to actual post or do development with the engine, but still keeping track of updates and posts, life and all that. smile

Life is a bit boring and so... Game Engine development and game development never stops!

I have succesfully, manually, inserted the char into a worl without the MMO foundation framework, and I tracked the issue down to server-client communication that is causing the crash now. Getting there! smile
04-18-2021 08:38 AM
Find all posts by this user Quote this message in a reply
Post Reply