• Zombie NPC help? NavSetGoal problems
    6 replies, posted
Hi, For my first Lua project i decided to make a basic zombie survival gamemode. I have hit a problem! I have realised the zombies have a set search radius in which they will look for enemies. I have used the code below to try to overcome this problem but it doesn't work. Any ideas why it doesn't work or on other ways around the problem? [Quote]function spawngrass(ply,cmd,args) ent = ents.Create("npc_zombie") pos = Vector(-1948.037842, -468.457189, -84.020981) ent:SetPos(pos) ent:Spawn() ent:NavSetGoal(ply:GetPos()) ent:Activate() end concommand.Add("sp2", spawngrass)[/Quote]
[lua]npc:SetLastPosition( pos ) npc:SetSchedule( SCHED_FORCED_GO )[/lua]
[QUOTE=CmdrMatthew;28192580][lua]npc:SetLastPosition( pos ) npc:SetSchedule( SCHED_FORCED_GO )[/lua][/QUOTE] Okay, Thanks but where does this go?
Use that to send the npc to the position you want it to. Just replace pos, with where you want it to go. [lua]function spawngrass(ply,cmd,args) ent = ents.Create("npc_zombie") pos = Vector(-1948.037842, -468.457189, -84.020981) ent:SetPos(pos) ent:Spawn() ent:Activate() ent:SetLastPosition( ply:GetPos() ) ent:SetSchedule( SCHED_FORCED_GO ) end concommand.Add("sp2", spawngrass)[/lua]
[QUOTE=CmdrMatthew;28193714]Use that to send the npc to the position you want it to. Just replace pos, with where you want it to go. [lua]function spawngrass(ply,cmd,args) ent = ents.Create("npc_zombie") pos = Vector(-1948.037842, -468.457189, -84.020981) ent:SetPos(pos) ent:Spawn() ent:Activate() ent:SetLastPosition( ply:GetPos() ) ent:SetSchedule( SCHED_FORCED_GO ) end concommand.Add("sp2", spawngrass)[/lua][/QUOTE] I have tried this and they still just stand there. They only move when i get close enough( around 2000 units)
1. You need nodes 2. That's the method I originally used, it's shit, try using: NPC:UpdateEnemyMemory( someplayer ,someplayer:GetPos()) inside a timer which repeats every 0.5 seconds
[QUOTE=Wunce;28249153]1. You need nodes 2. That's the method I originally used, it's shit, try using: NPC:UpdateEnemyMemory( someplayer ,someplayer:GetPos()) inside a timer which repeats every 0.5 seconds[/QUOTE] You Beauty! I use the following and it works from everywhere on the map. Cheers [lua] function spawngrass(ply,cmd,args) ent = ents.Create("npc_zombie") pos = Vector(-1948.037842, -468.457189, -84.020981) ent:SetPos(pos) ent:Spawn() ent:Activate() timer.Create("time", 0.5, 0, function() ent:UpdateEnemyMemory( ply, ply:GetPos ) end end concommand.Add("sp2", spawngrass)[/lua] Cheers Jordan Croft
Sorry, you need to Log In to post a reply to this thread.