Enemies in the 3D Game Kit

Geprüft mit Version: 2018.1

-

Schwierigkeitsgrad: Anfänger

We have 3 premade enemies in the 3D Game Kit. They can be found in Prefabs > Characters > Enemies > […..]

The enemies are Chomper, Spitter and Grenadier. Chomper is a close range melee enemy, Spitter is a long range projectile enemy and Grenadier is a boss type enemy with specific attack patterns, a mix of projectile, melee and a shield burst defense.

Let’s place a Chomper in the scene for Ellen to fight:

  • In the Project Window go to Prefabs > Characters > Enemies > Chomper

  • Drag Chomper into the Scene View

  • Use the Transform Tools to position Chomper where you like

A large dark blue semi-circle will appear in front of Chomper, this is his Detection Radius. When Ellen walks into this area, he will chase and attack her.

Let’s reduce the area in which he can see, with Chomper selected in the Hierarchy.

  • In the Inspector, navigate to the Chomper Behaviour Component

  • Expand Player Scanner by click the arrow next to it

  • In Detection Radius, set the value to 3

Let’s also make Chomper only be able to see from the front:

  • Slide the Detection Angle Slider to 180

Now Chomper can only see what is in front of him and at a much closer distance.

Note: To remove this Gizmo from the Scene View, collapse the Chomper Behaviour Component.

  • Press Play and run near the Chomper

Chomper will detect Ellen, but will only run on the spot. We need to tell Chomper where he can move on the ground, we do this by adding a NavMesh Surface.

  • In the Hierarchy click on the Plane

  • In the Inspector go to Add Component

  • Search for NavMeshSurface

  • Hit Enter on the Keyboard or click on the Script to add the Component to the Plane

  • Navigate to the Nav Mesh Surface Component

  • Set Agent Type to Chomper (This is used for all enemy types)

  • Set Include Layers to Nothing

  • Now on Include Layers, select Environment

  • On Include Layers, select Vegetation

  • At the bottom of the Nav Mesh Surface Component click Bake

A light blue surface will appear on top of the ground moving platform. This tells any enemy you place in the scene where they can walk.

  • Press Play and run in front of Chomper

Chomper will now run after you and attack!

  • Use Left Mouse Click to attack with your Staff!

Chomper will die after one hit. To increase this:

  • In the Hierarchy, select Chomper

  • In the Inspector navigate to the Damageable Component

  • Increase Max Hit Points to how many hits you want Chomper to take before he dies. Ellen’s Staff deals 1 Hit Point