• Getting an NPC to follow a player
    4 replies, posted
I am trying to get a npc to follow me using ai_goal_follow [url]https://developer.valvesoftware.com/wiki/Ai_goal_follow[/url] But I am not familiar with this entity so I have not been able to get it to work so far. I have tried it in dozens of combinations with no success. [CODE] local res = ply:GetEyeTrace() -- Create the npc and spawn it at my view ent = ents.Create("npc_alyx") ent:SetKeyValue("name", "cunt") -- for the actor to affect attribute ent:SetPos(res.HitPos) ent:Spawn() -- Make her friendly for the target entity option ent:AddEntityRelationship(ply, D_LI, 999) -- Set the name on myself ply:SetKeyValue("name", "fuck") -- Create the follow entity ent = ents.Create("ai_goal_follow") ent:SetKeyValue("maximumstate", "2") ent:SetKeyValue("formation", "0") ent:SetKeyValue("targetentity", "fuck") -- Should follow me ent:SetKeyValue("actorstoaffect", "cunt") -- Using the npc I just created ent:SetKeyValue("startactive", "1") ent:SetKeyValue("searchtype", "0") ent:Spawn() ent:Activate()[/CODE]
There is actually a tool for this, you don't really need a code, if you want to have the code, I'm sure somebody can still help you, Here's the tool for it. [url]http://steamcommunity.com/sharedfiles/filedetails/?id=104486597[/url]
I'm not looking for a premade tool.
[QUOTE=SEGnosis;42104973]I'm not looking for a premade tool.[/QUOTE] You know, you could view the tool's lua code, and then use what you need...
[QUOTE=Tomvdr;42107791]You know, you could view the tool's lua code, and then use what you need...[/QUOTE] Is only available in the workshop which gets downloaded into a gma file and its a pain in the ass to try and unpack. I took it apart and it seems to use SetSchedule and SetLastPosition. Neither work for me.
Sorry, you need to Log In to post a reply to this thread.