About Store Forum Documentation Contact



Post Reply 
No mesh can be found with ObjectPtr ?
Author Message
Dwight Offline
Member

Post: #1
No mesh can be found with ObjectPtr ?
Hi there,

Zervox's helped greatly by providing a code snippet that should work for loading characters in the world. However, I get the following error message:

"Attempting to create character without Mesh".

Code:
class AI : Game.Chr
{
   Int ID;
   Vec OldLocation;
   Str Name;
  
   void spawn(Str name, UID &obj, Int id, Vec pos)
   {
      Object ai = *ObjectPtr(UID(3693918013, 1099588927, 3132059316, 3366906225)); // uid is that of Esenthel Warrior
      //mesh = ai.mesh(); // This does not solve it
      
      Flt y = Game.World.hmHeight(pos.xz(),true)+0.6f;                                                
      T.pos(pos+Vec(0,y,0)); //Add Y so that it doesn't spawn just under the map.
      
      //Game.World.objCreateNear(ai, Matrix(1.8, pos));
      
      super.create(ai); //Create the object.

      Name = name; //Add specifics read from server.
      ID   = id;
  
   }
}
Memb<AI> ai;

Does anyone have an idea? The ObjectPtr should contain the mesh, but it's not finding them. I have tried loading different objects (Human, Warrior, own model), yet to no avail.
04-21-2021 11:03 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: No mesh can be found with ObjectPtr ?
Hello,

Please use this code:
Code:
class AI : Game.Chr
{
   Int ID;
   Vec OldLocation;
   Str Name;
  
   void spawn(Str name, UID &obj, Int id, Vec pos)
   {
      Flt y = Game.World.hmHeight(pos.xz(),true)+0.6f;                                                
      T.pos(pos+Vec(0,y,0)); //Add Y so that it doesn't spawn just under the map.
      
      //Game.World.objCreateNear(ai, Matrix(1.8, pos));
      
      super.create(*ObjectPtr(UID(3693918013, 1099588927, 3132059316, 3366906225))); //Create the object.

      Name = name; //Add specifics read from server.
      ID   = id;
  
   }
}
Memb<AI> ai;
Game.Chr needs the object to be located in the cache, but you make a local copy "Object ai=", so it's outside of the cache.
Alternatively you can do:
Code:
ObjectPtr ai=UID(..);
super.create(*ai);
04-21-2021 02:18 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #3
RE: No mesh can be found with ObjectPtr ?
(04-21-2021 02:18 PM)Esenthel Wrote:  Hello,

Please use this code:
Code:
class AI : Game.Chr
{
   Int ID;
   Vec OldLocation;
   Str Name;
  
   void spawn(Str name, UID &obj, Int id, Vec pos)
   {
      Flt y = Game.World.hmHeight(pos.xz(),true)+0.6f;                                                
      T.pos(pos+Vec(0,y,0)); //Add Y so that it doesn't spawn just under the map.
      
      //Game.World.objCreateNear(ai, Matrix(1.8, pos));
      
      super.create(*ObjectPtr(UID(3693918013, 1099588927, 3132059316, 3366906225))); //Create the object.

      Name = name; //Add specifics read from server.
      ID   = id;
  
   }
}
Memb<AI> ai;
Game.Chr needs the object to be located in the cache, but you make a local copy "Object ai=", so it's outside of the cache.
Alternatively you can do:
Code:
ObjectPtr ai=UID(..);
super.create(*ai);

Thank you very much Greg, it is much appreciated! I learned something new today grin

Next step.. Movement! grin
(This post was last modified: 04-21-2021 02:54 PM by Dwight.)
04-21-2021 02:36 PM
Find all posts by this user Quote this message in a reply
Post Reply