Unity : AI [Navmesh implementation (Part IV)]

NOTE : Even if we talk about IA and NavMesh, I’m take one moment to explain a little thing about collections in programming. Because I have see a lot of people have problems with this logic, (me too at the beginning!) and at the end is more easy than you think.

The point is this : every time we use a collection (Array, List, etc) we have to remember one simple thing : the first element is at 0 INDEX.

Now, .Length or .Count, returns how many elements are in the collection.
It means that if we have an Array of 5 elements,
.Length RETURNS 5, NOT 4.

And in this case, for example, _currentPoint represent the INDEX.

_currentPoint == _points.Count,
_currentPoint is 5 BUT _point.Count is 6
and 6 DOES NOT EXIST, because we have only 5 indexs.
And that’s why we have this error -> OUT OF THE BOUND OF THE LIST<>.

And at the end we move to _currentPoint.

--

--

--

Always in love with programming, even if late (I'm already 39 years old) I decided to follow my dream! We will see how far my passion will take me!

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

Recommended from Medium

ORM, Object-Relational Mapping, Shoplazza geekZone

I’ve Got The World On A String…(…Argument Imbedded Inside My Show Route)

The First Major WordPress Release of 2020 is Now Available!

Ansible : how to create roles and install prometheus, grafana and node-exporter

Lead to Quote — What is it? And how to get estimating right.

Ubuntu 20.04中實用指令(會持續更新)|Practical commands in Ubuntu 20.04 (To be continued...)

Specific whole probably might.

Arbitrum Rollout: Demo DeFi ecosystem built on Arbitrum’s Layer 2 testnet

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
Matteo Lo Piccolo

Matteo Lo Piccolo

Always in love with programming, even if late (I'm already 39 years old) I decided to follow my dream! We will see how far my passion will take me!

More from Medium

Unity : NavMesh (Offmesh Links)

VR Development — Day #2

Converting from 3D to 2D in Unity

Unity Performance Optimization: Animation Module