Game Development Reference
In-Depth Information
}
}
}
Our
AI
class is derived from
CharacterClass
. So, if we open
Character-
Class
, we will see the
UpdateHitPoint()
function getting called from the
OnCollisionEnter()
function. We will also see that there is the
ragdoll
GameObject
variable that we use to instantiate a
ragdoll
object. This func-
tion will check whether the rocket hits the AI or not. If the AI is hit and its hit
point is equal to
0
, we will create a
ragdoll
object for the scene and add the
rocket force to the
ragdoll rigidbody
object to make this more realistic.
17. Save the
AI
script and go back to the
Resources/Prefabs
folder in the
Pro-
ject
view. Click on the
robotAI_C#
(for C# users) or
robotAI_JS
(for Unity
JavaScript users) prefab, and go to the
Inspector
view, as shown in the following
screenshot:
18. In the
Inspector
view, we will go to the
Ragdoll
property in the
AI (Script)
sec-
tion, and drag
robotAI_ragdoll
to this
Ragdoll
property, as shown in the follow-
ing screenshot: