Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision | ||
quick:agents [2020/09/03 09:24] – pedro | quick:agents [2020/09/03 09:46] – pedro | ||
---|---|---|---|
Line 17: | Line 17: | ||
- Add a cube to the enemy above the `shootpoint` scaled to (0.1, 0.1, 0.3) at the relative position (0, 0.5, 0.5). This will tell us where the enemy is aiming. | - Add a cube to the enemy above the `shootpoint` scaled to (0.1, 0.1, 0.3) at the relative position (0, 0.5, 0.5). This will tell us where the enemy is aiming. | ||
- | {{: | + | ![](: |
In addition, we have to modify the way the enemy shoots in order to fit the training and the execution of the agent. Specifically, | In addition, we have to modify the way the enemy shoots in order to fit the training and the execution of the agent. Specifically, | ||
Line 23: | Line 23: | ||
The script `FiredBullet` consists in giving intelligence to the bullet, so it can tell if the it has impacted the player, besides autodestroy passed 2 seconds (or whatever the time indicated by the parameter). Additionally, | The script `FiredBullet` consists in giving intelligence to the bullet, so it can tell if the it has impacted the player, besides autodestroy passed 2 seconds (or whatever the time indicated by the parameter). Additionally, | ||
- | < | + | |
+ | ```csharp | ||
using UnityEngine; | using UnityEngine; | ||
Line 62: | Line 63: | ||
} | } | ||
} | } | ||
- | </ | + | ``` |
The code should be self-explanatory, | The code should be self-explanatory, | ||
Line 72: | Line 73: | ||
The script `EnemyShoot` implements the shooting capacity of the enemy agent. We create a C# script that extends `Monobehaviour` based on the previous script `ShootOnce`. | The script `EnemyShoot` implements the shooting capacity of the enemy agent. We create a C# script that extends `Monobehaviour` based on the previous script `ShootOnce`. | ||
- | < | + | ```csharp |
using UnityEngine; | using UnityEngine; | ||
Line 149: | Line 150: | ||
} | } | ||
} | } | ||
- | </ | + | ``` |
We have to note the following points: | We have to note the following points: | ||
Line 160: | Line 161: | ||
Finally, we create the C# script `EnemyAgent`, | Finally, we create the C# script `EnemyAgent`, | ||
- | < | + | ```csharp |
using UnityEngine; | using UnityEngine; | ||
Line 253: | Line 254: | ||
} | } | ||
} | } | ||
- | </ | + | ``` |
This class has three main methods that are overriden from the `Agent` class. Explaining why this methods have to be overridden and how Agent class works is out of the scope of this guide. The concrete implementation of these methods is described below. | This class has three main methods that are overriden from the `Agent` class. Explaining why this methods have to be overridden and how Agent class works is out of the scope of this guide. The concrete implementation of these methods is described below. | ||
Line 275: | Line 276: | ||
- | {{: | + | ![](: |
Line 284: | Line 285: | ||
- | {{: | + | ![](: |
Line 292: | Line 293: | ||
- | {{: | + | ![](: |
Line 303: | Line 304: | ||
- | {{: | + | ![](: |
Line 309: | Line 310: | ||
- | {{: | + | ![](: |
Line 322: | Line 323: | ||
- | {{: | + | ![](: |