Can't SetLocation() in a pawn?

The best and quickest support by a group of top-notch editing specialists, guaranteed!

Moderator: Forum Guards

Can't SetLocation() in a pawn?

Postby Cozmo » Thu Feb 17, 11 1:53 pm

Yes more NPC movement stuff. :oops: So I have a pawn that can be ordered to follow you in MP. I want it so that they will teleport to you once you're too far away from them, so they can "follow" you on trains around the city, get past BlockMonsters and so on.

The code seems fine - the debug message shows up when it should be called, but they're just not doing it? This is the relevant code so far...

Code: Select all
   if((DXP != None) && (Enemy == None))
   {
      if(VSize(Location-DXP.Location) > 1200)
      {
         self.SetLocation(DXP.Location);
         broadcastmessage("debug: tele");
      }
      else if(VSize(Location-DXP.Location) < 200)
      {
         gotoState('Standing');
      }
      else
      {
         GetMoving();
      }
   }


This code is in the pawn in a Timer(), with DXP being the player. I've tried it with and without "self." before the function. Something to note is that the pawn is in a new following state, but this is global code. Anyone have any idea about this? I wanted to release the mod later today but this is important (and frustrating).
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby Dae » Thu Feb 17, 11 7:08 pm

did you try logging DXP.Location?
User avatar
Dae
Alpha
 
Posts: 12086
Joined: Sat Sep 06, 03 4:40 pm

Postby Cozmo » Thu Feb 17, 11 8:03 pm

Just tried that. It seems to have my location fine

Image

This problem is incredibly silly.
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby Dae » Fri Feb 18, 11 1:26 am

wild guess... try SetLocation(DXP.Location+vect(2,2,2));
User avatar
Dae
Alpha
 
Posts: 12086
Joined: Sat Sep 06, 03 4:40 pm

Postby Cozmo » Fri Feb 18, 11 2:34 am

Ooh, it does seem to be a collision thing (I suspected, but no idea how to check native functions). Made it slightly bigger +(100,100,100) and it works now. Will now figure out how to make sure NPCs don't get stuck in walls. Thanks a lot Dae :)
Cozmo_RPG (v1 & v2)
MPConversations - A tool for creating multiplayer RPG stuff
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby Cozmo » Fri Feb 18, 11 8:33 pm

For anyone interested, I changed it so that the NPC spawns 2 feet behind the player, so it'll be cleaner / less chance of getting stuck in something.

Code: Select all
   local vector loc;

   loc = DXP.Location;
   loc -= 32.0 * DXP.CollisionRadius * vector(DXP.ViewRotation);
   loc.Z += DXP.CollisionHeight * 0.9;

   SetLocation(loc);
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK


Return to Editing issues

Who is online

Users browsing this forum: No registered users and 41 guests
cron