# Beyblade-ish Enemy AI Help

 0 Not exactly beyblades but like two balls one controlled by player another by computer or even more than one trying to throw each other out of the stadium. Can't get to know where to start .. Thankx more ▼ asked Dec 04 '11 at 01:00 PM Anonymous 1 98 ● 16 ● 18 ● 22 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

1 answer: sort voted first
 0 You will need the A.I to know several things to make it work properly, although I'm only coming up with these things in my head now and hope you can develop them further. Your A.I needs to know: (I am assuming you have a circular stadium, if not you have to do some A.I way-point system or another path-finding solution) - Center position of the stadium - Radius of the stadium - Target transform (the player) to 'attack' Using those, you want it to have two things to do. 1. Go towards the player 2. Stay away from the edge of the stadium, and be as close as possible to the center. This is your basic A.I. From here you can develop things like checking player and self velocity to try dodge player attacks. To make things fun, give the player and A.I a different physic material (under box, sphere or capsule collider) like bouncy. Good luck! more ▼ answered Dec 04 '11 at 01:33 PM Rabwin 389 ● 11 ● 15 ● 27 wow you totally kick started me! if you can just tell me the code for 'to go towards something like player or a checkpoint set in the center of stadium' i think i would be able to make a script out of it Dec 04 '11 at 01:50 PM Anonymous 1 How about using the in-built unity funciton Vector3.MoveTowards Three parameters: transform.position, target.transform.position, speed.Editted answer: now says correct component where you change physic material. Dec 04 '11 at 02:10 PM Rabwin yup.. its coming .. one more thing how will the enemy movetowards two objects ie player and center of the stadium ? and about dodging if the enemy is moving towards player how will it dodge it ? i mean u can't dodge something you are moving towards too XD Dec 04 '11 at 03:14 PM Anonymous 1 You need to put some if statements in there to check what state the A.I should be in I guess. Am I close enough to the center? Should I attack the player? The player is coming at me so maybe I should move away?Things like these require some logic using distances, measuring velocity and direction and whatnot :) Dec 04 '11 at 03:21 PM Rabwin Thanks man.. helped much its night here so i am going in bed but tomorrow i will give a shot to this.. thank you very much! it would be my first time scripting an AI from scratch :D marking this as answer, but hope when i comment here a question you will reply Dec 04 '11 at 03:30 PM Anonymous 1 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
Your answer

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2492
x32
x7
x2
x1

asked: Dec 04 '11 at 01:00 PM

Seen: 658 times

Last Updated: Dec 06 '11 at 09:52 AM