Another Player Chasing System- Game Dev Series 124

Quick guide of create AI system by using Character Controller.

We have created AI system by using NavMeshAgent in the previous articles. In this article, we will use the same controller as Player to make enemies moving.


The idea of making enemies moving by its Character Controller is locating where Player is, and trying to approach. This would be quite similar to using NavMeshAgent, and the difference would be there is no area limit to Character Controller.
You can make Character Controller walking through almost everywhere.

The setting

Let’s assume that we all have the object of enemy.
Add Character Controller and remove the collider.

Then created a script to handle the enemies movement, and get the reference of Character Controller and Player.
Inside Update(), first we need to calculate the direction of Player.

To prevent enemies snapping to Player within 1 frame, we added “normalized” to downsize the calculation result.
Then we need to limited the Y-axis position to prevent it leaning. And also use “direction” as the rotation value to facing Player.

Now we can get the velocity by using direction times speed. And make it affected by gravity if it is not on the ground.

After all these, the final step is making him walks to Player.

And now you have got an auto-chasing enemy.




A passionate gamer whose goal is to work in video game development.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

70 years Back to the Future: Turing’s insights in the year of pandemic

The Future of AI in Banking: From Banking Experience Upgrade to Transforming Mankind

Demystifying Computer Vision

Bias, Toxicity, and Fairness in A.I

Fighting Illegal Content with Artificial Intelligence

Living Systematic Reviews: Real-time Evidence Monitoring Powered By Natural Language Processing…

AI and Ethics: The Perils Ahead

How mature is your remote support offering? Evaluate it with this Capability Maturity Model

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
S.J. Jason Liu

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

More from Medium

Day 103: Creating A Ledge Grab in Unity Part 1

Building A Stealth Game — Creating Waypoints For Your AI Guards

GamePad Support w/ New Unity Input System

Alter Your Pre-Built Texture Map- Game Dev Series 152