• NPC Moving to player
    15 replies, posted
After using the following code to spawn a zombie; [lua] local e=ents.Create("npc_zombie"); e:SetPos(Vector(100, 203, 10)); e:Spawn();[/lua] It will not walk to the player until it has seen the player. The map is noded, hoverever it does not seem to pick up a node eigther.
Do some research on chrisasters HL2 Chess in Gamemode development and look to see how he does it:coolfish:
No no no, that is completely diffirent. Have you even read the op?
[QUOTE=_NewBee;30783108]No no no, that is completely diffirent. Have you even read the op?[/QUOTE] Yes I read before replying, and I was giving you advice to look for yourself since all your doing is being lazy.
Doesn't he use ragdolls? I didn't think he used NPCs
I still need help on this, by the way. By the way, npc_zombie is a default hl2 NPC, if that helps.
I have found out that it does work if I place the NPC in the map using hammer. But not using when using lua.
Use e:SetSchedule( SCHED_FORCED_GO, player:GetPos() ) Untested.
That doesn't work, but I've found out what does thanks to the valve developer wiki. Ill just leave what i've found right here, so people who might need it later can see it. [lua] --edited for posting. local e=ents.Create("npc_zombie"); e:SetPos(Vector(0,0,0)); e:Spawn(); timer.Simple(1,function() e:SetTarget(Entity(1)); e:SetSchedule(SCHED_TARGET_CHASE); end) [/lua]
Oh right. I've had troubles in the past with the SetTarget() commands so I generally avoid them if possible. Glad to see you got it working, awesome that you posted it for the community too.
Wouldn't another solution be to set the angle of the zombie to face the target so it automagically picks him up?
Would be a dumb way to do it, honestly. Did you mean automatically?
I meant when the SetPos() occured, to just set the angle to the player so the npc would have it's lock, not sure if there is a npctarget target/hook to see if the npc ever got a different target, that would have been my approach at it.
There is still no assurance that the zombie will attack the player.
[QUOTE=Hyper Iguana;30842648]I meant when the SetPos() occured, to just set the angle to the player so the npc would have it's lock, not sure if there is a npctarget target/hook to see if the npc ever got a different target, that would have been my approach at it.[/QUOTE] You could do that, but my zombies spawned in an arena where they can't see the player, because it doesn't look good if you can see NPCs spawn. It never does.
Arena? I'm guessing that this is like a player vs. zombie gamemode. Wouldn't it be best to just imbed the spawns into the map via. SourceSDK?
Sorry, you need to Log In to post a reply to this thread.