NPC targeting offscreen enemies

O Ilusionista

Captain 100K
Is there a way to prevent an NPC to target an enemy which is offscreen?
On my game, NPC gets too close to the screen edge trying to attack an enemy who isn't in the screen yet.

I can think about some script to prevent it, but I would like to know if there is an easier way.

Thanks.
 
Not that I can recall. NPCs use the enemy AI routine in chase mode. You might mess around with AI flags to make it less aggressive about chasing enemies, but that would probably make it less useful and it still might wander toward edges.

The only other non script thing I can think of would be a tighter leash to parent. But be careful, if an NPC goes outside of max range, it instantly teleports to parent while playing RESPAWN. You'll want to make some kind of animation to keep it from looking silly.
 
Damon Caskey I think I have an ideia - pseudo code:

- Check if the  next target (findtarget) is outside of the screen.
- If it is, then (if I am not wrong) I can sort all the available targets/enemies from the level
- If the new target is different from the previous one, change the target to this new one by using "custom_target".

 
O Ilusionista said:
Damon Caskey I think I have an ideia - pseudo code:

- Check if the  next target (findtarget) is outside of the screen.
- If it is, then (if I am not wrong) I can sort all the available targets/enemies from the level
- If the new target is different from the previous one, change the target to this new one by using "custom_target".

Yeah you can do that. You'll just need to be good with conditions to pick the right targets. Also keep in mind once a custom_target is set it never unsets. The only thing your NPC will ever think of is kicking that one guys a** until it stops being funny.  :o

DC
 
Yeah, and that's the whole point - all the built in targeting can switch around. Custom_target specially overrides all that until you set it to something else. You could have Loki b**ch slapping Thor from behind and he wouldn't so much as turn around from beating on a random lamp post.

"Loki can wait, thoust your END this day, foul bringer of street light!"

DC
 
Back
Top Bottom