Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

move to waypoint script

Page: 1 of 1
 HdVaderII
03-10-2008, 4:46 PM
#1
I've been trying to find a way to make an npc move to a waypoint, but I haven't really figured out how. Would anybody feel like showing me a script on how to do that?
 Stream
03-10-2008, 5:03 PM
#2
Try this;

void main () {

object oNPC=GetObjectByTag("NPC_TAG");

AssignCommand(oNPC, ClearAllActions());
AssignCommand(oNPC, ActionForceMoveToLocation(GetLocation(GetObjectByT ag("WP_TAG", 0)), 0));

}

That space in tag shouldn't be there, not sure what's causing it but you'll need to take it out.

--Stream
 HdVaderII
03-10-2008, 5:04 PM
#3
and what if I want to make him dissapear after walking to the waypoint?
 Stream
03-10-2008, 6:23 PM
#4
The code would be exactly the same except add a delayed destroy function, so the overall code would be;


void main () {

object oNPC=GetObjectByTag("NPC_TAG");

AssignCommand(oNPC, ClearAllActions());
AssignCommand(oNPC, ActionForceMoveToLocation(GetLocation(GetObjectByT ag("WP_TAG", 0)), 0));
DelayCommand(9.5, DestroyObject(GetObjectByTag("NPC_TAG", 0), 0.0, 0, 0.0, 0));

}

The 9.5 is the time in seconds to delay the command, you'll probably need to alter this to get it right, it depends on how far they have to walk first, if they're hurt, which will make them walk slower etc. Just try it a few times, if they get to the waypoint and are stood there for too long drop it down, and if they fade away before they reach the waypoint then increase it.

--Stream
 HdVaderII
03-10-2008, 6:36 PM
#5
do I place anything instead of the zeroes in the script?
 DarthJebus05
03-10-2008, 6:49 PM
#6
DelayCommand(9.5, DestroyObject(GetObjectByTag("NPC_TAG", 0), 0.0, 0, 0.0, 0));


9.5 is 9 and a half seconds, thus if you want it to be 15 seconds, you would change it to look like this:

DelayCommand(15.0, DestroyObject(GetObjectByTag("NPC_TAG", 0), 0.0, 0, 0.0, 0));


So no, you don't change any of the 0's.
 HdVaderII
03-10-2008, 7:09 PM
#7
Thanks a lot!
 DarthJebus05
03-10-2008, 7:16 PM
#8
No problem, anytime.
Page: 1 of 1