Need some help programming basic AI movement
Looking for a little help programming some basic AI movement separation. My code is here: https://codeshare.io/X8n6JE
Here is a video of the behaviour without the "new section" of the code: https://youtu.be/jKEyI7LUz1c
Here is a video of the behaviour with the "new section": https://youtu.be/xYBDHc7G3_E
the new section is taken from a unity forum and is to try to stop the AI from crowding and clumping together. I am unsure how to integrate it properly with the code I already have and if it is the best solution. I am trying to achieve the AI kind of fanning out, but still chasing the player, just not too close together. The problem I'm having is, it looks very clunky and like it is not working very well, the AI seem to get stuck behind each others colliders and move towards the player much slower than they should. I wondered if it would be possible to combine the direction towards the player and the direction away from each other into a new vector, but because I am just beginning in coding I can't think how to do this. Does anyone have any experience of doing this kind of thing or is able to help me clean up and fix my code a little?
Your answer
Follow this Question
Related Questions
New Vector2 won't take effect when called from another script in the same GameObject. 0 Answers
Vector2 intersection 0 Answers
Enemy direction going crazy after collision 1 Answer
How to SHOOT an object on a curved path without using Rigidbody 2 Answers
Movement causing infinite loops in OnTriggerEnter and OnTriggerExit. 1 Answer