Games Engines Theory 3 NPCs and AI

This week's Objectives

Look at NPC implementations

Investigate ways of implementing AI behaviour

Waypoints and other information and how they are used

(C) 2k Games- Bioshock infinite

What is an NPC?

A non-player character (NPC), is any character that is not controlled by a player. In video games, this usually means a character controlled by the computer through artificial intelligence. These can have lots and lots of uses within the games scope.

Types of NPC

Can be broken down loosely into NPC and Bot

NPC by definition doesn't play the game. Bots however simulate a human playing the game

NPCs can be; Player controlled, in the background (and not even interactable), essential to the story, provide items/ info/ etc. they have a hundred and one uses. NPCs (and Bots) can be used to improve the difficulty (either making it harder or easier) by adding or subtracting them as well as improving their play.

A tried-and-true way to get players to care about a video game character is to use what I call the Yorda Effect. Named after the non-player character (NPC) from Ico (SCEA, 2001), Yorda is a young girl that Ico has to protect from enemies and help traverse the environment as the pair attempt to escape a mysterious castle. ... If Yorda dies, so do you.... The character needs to offer limited assistance to the player in the form of healing, assisting in combat, providing extra ammo, or solving puzzles. If designed correctly, this co-dependency between characters creates a protective relationship in which the player comes to genuinely care about the welfare of the NPC.

From Level UP The guide to great video game design

Task

Read the above and pull out their top 3 tips for creating compelling NPCs

How are NPCs implemented in Unity

Your tutorials showed you a few different ways, these were mostly unfriendly AI- aimed at attacking and damaging you and chasing the player.

Movement was accomplished by either the AI moving in a straight line always towards the player or using a NavMesh and NavMeshAgent. The former is bad but does at least allow you to move in 3D, the latter is easy to use but has it's limitations. There are other alternatives to both on the app store and creating your own.

I intended to write a brief easy to read summary of A* path finding, then I came across this post from Ray Wenderlich's site. It's a much better depiction than I could write and even has cats, who doesn't like cats.

NPCs and Waypoints

A lot of games require AI to be moving around continuously, to do this we implement waypoints.

Waypoints are invisible placeholders within the gameworld that can be referred to. Generally they may have little more than their transforms (pos, rot, scale) and perhaps some logic (in the form of collider/trigger and script). They could even be attached to other things such as meshes and objects.

The AI implementation then sends it to that place, when it reaches that place it may through the use of triggers and colliders trigger some more logic. You can create a looping list- when it gets to the end, return to the start, there are lots of possibilities.

Alternatively, you may want NPCs to follow commands, in the standard RTS like below the player clicks and a raycast collides with the ground the place hit is sent to the NPC and it then goes there.

(C) EA Games- Red Alert 2

Other interactions?

AN NPC that just walks would not be a hugely useful NPC, we want it to do other things. We do this by linking in other elements of game logic we've discussed prior. One instance is raycasting, this can be used for shooting, interaction, pathfinding, all sorts.

Task

In pairs or small groups try to decipher a way an AI could detect and attack a player using Raycasting. (Imagine an FPS enemy that needs to be able to turn a corner and see the player then shoot the player).

The following is a final thought from extra credits- it talks about exit points and how npcs can be used to fuel a reluctance.

Created By
Simon Hunt
Appreciate

Report Abuse

If you feel that this video content violates the Adobe Terms of Use, you may report this content by filling out this quick form.

To report a Copyright Violation, please follow Section 17 in the Terms of Use.