Aller au contenu

Photo

NPC jumps to waypoint instead of walking


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
nametab

nametab
  • Members
  • 70 messages
Hi there,
Had a bit of a break from the toolset, but now I'm back to torment you with more questions about the toolset and it's flaws.

After some trouble with "ga_ambient" I created my own script that makes an NPC walk to random waypoints across one area. Luckily, this one works just fine but the way my NPC is fulfilling his task is far from satisfactory. When the next chosen waypoint is really far away, the NPC walks toward it for a short time and then just immediately jumps to it, as if he's using a teleportation spell (but without the special effects). This problem does not occur when the distance between point A and point B is relatively short.

The script I'm using is an OnHeartbeat one, perhaps this is somehow a problem? I want my NPCs to walk the full path instead of just jumping to their destination when they get tired of moving their legs.

#2
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
The reason is that the function ActionMoveToObject() has a time out parameter, which I think is 30 seconds by default (you can change this). If they don't reach the next WP within that time, they get jumped there. The reason for this is in case the creature gets "stuck" on something and can't make it there on their own. Also this is why they move all the way on short tips (under 30 seconds apart) and jump on the long hikes.

To solve, either set the timeout to a higher value or have the WPs closer together.

Modifié par _Knightmare_, 06 octobre 2010 - 02:10 .


#3
nametab

nametab
  • Members
  • 70 messages
Changing the timeout value sounds like the perfect solution, how do I do that?

#4
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Oops, the function I was meaning is actually called ActionForceMoveToObject() and not ActionMoveToObject(). If you are using the second one, try the first, there's a parameter in there to set the time out. Look up the function in Script Assist and it will tell you which parameter. Set it to like 60 or whatever instead of the default 30 (measured in seconds here).

Modifié par _Knightmare_, 06 octobre 2010 - 02:46 .


#5
Shallina

Shallina
  • Members
  • 1 011 messages
Having multiple waypoint insead of one far away is the best solution. You can be sure that your NPC won't be stuck and will walk a satisfactory path.

#6
nametab

nametab
  • Members
  • 70 messages
Some of the waypoints are very close to each other, some are not. After each heartbeat the NPC draws one of the waypoints and moves toward it, so there's no specific path here really.



Anyway, the trick with the timeout parameter seems to work just fine, so thanks for the help!