Phodex Games Posted September 14, 2017 Share Posted September 14, 2017 Hey, I am currently working on my AI, and I wonder what would be a good way, to make my NPC hold a specific distance to the player. In my case I need it for my AI behavior when it is using range weapons. I think a nice idea is to let the AI find a random point, which keeps a few conditions like, 10 units away from player, not outside of the map, not inside another object. But how to realise that. I would be very thankful if you can give me ideas, examples, descriptions etc. Quote Link to comment Share on other sites More sharing options...
thehankinator Posted September 14, 2017 Share Posted September 14, 2017 You could do something hacky like this. Do this for like 10 or 20 points around the player using sin() and cos() multiplied by the distance you want (10 in your example) from the player's global location. Use World:Pick() from that point to the player, this tell you if this point has line of sight to the player. If your level has walls then this will also tell you if you are on the map or not. If your level does not have walls you could do another World:Pick() from the point to the same point with a big -y value to see you are over an object. If your level is not flat this can get complicated, if there are no ceilings you could use World:Pick() with some big +y value to a big -y value to find the ground, then do the line of sight pick from that point to the player. You wouldn't want to run this every frame but it should work. 1 Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted September 15, 2017 Author Share Posted September 15, 2017 Very interesting indeed, thank you for that. I guess I can build up on that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.