If i want to force an npc to find the nearest player and attack him how to i do it? not from the npcs code but from an independent lua file.
You could try
[lua]
npc:SetEnemy( ply );
npc:SetLastPosition( ply:GetPos() );
npc:SetSchedule( SCHED_CHASE_ENEMY );
[/lua]
Wouldn't that just make it track the very first enemy that triggers it's code? He said closest so wouldn't you do a CheckInSphere for the closest player perhaps?
Why would you need to set the schedule? Wouldn't just setting the enemy be sufficient?
[QUOTE=Killer_Steel;16060980]Wouldn't that just make it track the very first enemy that triggers it's code? He said closest so wouldn't you do a CheckInSphere for the closest player perhaps?[/QUOTE]
I didn't realize he hasn't even found the closest enemy yet, I was showing him a method to make it attack.
Sorry, you need to Log In to post a reply to this thread.