Jump to content

Home

Spawning NPCs in scripts?


riceplant

Recommended Posts

I'm having a problem spawning NPCs in scripts. They spawn in fine, but any 'affect's in the script don't work, and I have to restart the script to affect them, it working fine the second time. Will it work properly if I, after spawning my NPC, run a seperate script to affect them, and if so, do signals cross between different scripts? Also, how do I run another script from a script? It doesn't seem to work for me using 'run'.

Link to comment
Share on other sites

  • 2 weeks later...

Yes, your analysis is quite right. There seems to be a period of time, a lag, between the moment of spawning and the moment you can affect an NPC. Possibly you could just wait a while in a script before trying to affect, although I can't verify that, since it wouldn't really have suited my purposes. I have solved the issue by prespawning NPCs shortly before the cinematic, not in the cinematic script itself.

 

Also you should notice that spawnscripts do get executed always, but that of course disperses the cinematic script, and with the signalling approach, that's not something to be desired.

 

So, my advice is to spawn pretty much all the npcs you need in a cinematic just before you launch the actual cinematic script, not in the cinematic script itself. Well, there might be other ways, but this is the one I chose.

 

Run command does work, but it's sometimes a bit tricky, and may seem a bit less reliable than a script_runner. Make sure you have the path right and everything. But this won't necessarily solve the problem of affecting newborn npcs, mind you.

Link to comment
Share on other sites

What I do is, I have ALL the NPCs spawn before the level loads, give them all NPC_targetnames and make them invisible, then I make them "unvisible" and solid when I need them (at least for cutscenes.) On a normal playable level, just have 2 trigger_once's. The first spawns the NPCs, then right after that have a 2nd trigger_once that connects to a script_runner. Scripts that spawn NPCs don't affect them.

 

Its better to just simply have a trigger_once connected to the NPC, so when you walk into it they spawn.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...