Time for action - place a basic AI entity

Let's now add one of the most advanced and dynamic entities available to us within the sandbox application:

  1. In the RollupBar, click on the Entity button.
  2. Under the AI folder, find the Grunt tab.
  3. Click-and-drag the entity anywhere on your terrain within the perspective viewport.
  4. Switch to game mode near their location, and the Grunt object will immediately attack you, if you are within range.

When selecting the Grunt object, you will be presented with a huge variety of properties that have been previously set in the .lua script in the Entity Properties section of the RollupBar. The default settings of the Grunt object will suffice for this example, but it is recommended that you experiment with some of the parameters available.

What just happened?

You have placed your first enemy and can now interact with them. Having characters to breathe some life into our story and game gives us tons of gameplay possibilities by simply placing them in progressive and interesting ways. A common mistake when dealing with AI placement is that the characters are placed without being given a task or without being hidden slightly from view. Consider the placement of AI carefully. As this example showed you the procedure of getting an AI entity into the world, it is worth noting that the use of advanced spawning and scripting actions can be achieved using the flow graph, which is explained in the next chapter.

Have a go hero

Try adjusting some of the properties of your AI to make it more or less challenging. Change the attackrange parameter to a lower value so that the AI doesn't react until you are very close, or set it very far so that they react to you sooner.

Use the Faction parameter to have the AI fight each other or aid the player by setting them to oppose Faction objects.

Have a go hero

Create an archetype entity

Although not essential, it is very good practice, when creating games with a variety of enemies, to create different templates for the player to fight in. We call these templates archetypes. Archetypes store all the properties of their associated entity. For example, you can have archetypes of lights with certain settings, breakable objects with specific parameters, and finally AI entities with specific parameters. In the case of an AI archetype, some of the important parameters could be attackrange, Field of Vision, Health and some other properties.

The most important benefit of using archetype entities is when you consider trying to change every placed AI entities' properties across all levels. Without the archetype entities, you would have to physically go in and change all the instances of each character for it to reflect your changes. Using archetypes allows you to modify this once and affect every single instance across multiple levels at the same time.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.8.141