Implementing the player AI in unity


I started to create a Unity component that trigger the Player action

This is the Idea of areas to cover around the player and which action he has to take depending of what triggers in the different areas.

In unity I created GameObjects with a component RuleCollision that has a Box Collider 2D, when something that is in the list of tags hits the collider it will make a random number and will pickup one of the actions. 

Here is a screenshot of my Component, the actions are linked to the player

To link the actions I used the   UnityEvent  that can be Invoked.

List of all the player actions (than the I A can trigger, but can also be used by the player in player mode)


How I invoke the action 

To select the action I calcule a random value , then I go thought all the actions and trigger the right action with Invoke.

I have a timer (speedchange) that stop for some time to trigger the action, if not the  player will move like crazy.. 


Get Mecha City Fighter

Download NowName your own price

Comments

Log in with itch.io to leave a comment.

Great article! I like  your concept and how well you translated each part of it into Unity. This is really good stuff and a testament of your abilities to master  such tough tasks.

Thanks!!