Skip to Main Content
Building an RPG with Unity 2018 - Second Edition
book

Building an RPG with Unity 2018 - Second Edition

by Vahé Karamian
July 2018
Intermediate to advanced content levelIntermediate to advanced
366 pages
7h 48m
English
Packt Publishing
Content preview from Building an RPG with Unity 2018 - Second Edition

Enhancing the code

One last code implementation I would like to make before I close out the chapter, is to make sure that when we are in attack mode for the player character, the hit points will affect the NPC that it is intended for automatically. In other words, determine which NPC is closest to us based on our distance and view angle toward the NPC.

We have already created the logic to determine these quantities for the NPC character. We now need to implement something similar for the player character. Let's take a look at a partial listing of the code changes we need to make for the BarbarianCharacterMovement.cs script:

using UnityEngine;namespace com.noorcon.rpg2e{public class BarbarianCharacterController : MonoBehaviour{public Animator ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Unity 2020 Game Development

Hands-On Unity 2020 Game Development

Nicolas Alejandro Borromeo
Unity 2018 Cookbook - Third Edition

Unity 2018 Cookbook - Third Edition

Matt Smith, Chico Queiroz, Jate Wittayabundit

Publisher Resources

ISBN: 9781788623469Supplemental Content