About 'C-Sharp Lists For Custom Path'!

In this video (objectives)…

  1. The List<> syntax
  2. Lists vs arrays
  3. Creating a custom waypoint path.

After watching (learning outcomes)…

Use a simple list in C#.

(Unique Video Reference: 6_RR_CU2)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

I set myself a mini challenge to figure out naming the gameObject with the coordinates but I used

this.name = blockCoord;
instead of
gameObject.name = blockCoord;

Is how I’ve done it likely to have any negative repercussions down the track? I don’t fully understand this, but for some reason that’s where my mind went.

We’ll get more into that later, but meanwhile this old blog post of Brice’s may help…


Ah, that GIF is brilliantly succinct. I look forward to learning about the
nuances of using both.

1 Like

I’m attempting to use List<> but I’m receiving an error stating that the name Block could not be found and that I am missing an assembly reference. I’m not sure how to proceed without being able to use List<>. Thanks!

Can you post your full line of code you’re attempting to use.

Here is the code (Same as the video): [SerializeField] List < Block > path;

Here is the error code: Assets/EnemyMover.cs(7,27): error CS0246: The type or namespace name `Block’ could not be found. Are you missing an assembly reference?

So I don’t own the course itself so can’t check the videos but do you have a script and class named Block? The error suggests that it doesn’t exist.

I had a quick look at the code for the final version and can’t see any script named block.

Lists are normally declared as:

List<Type> variableName = new List<Type>();

so I’d expect something like List<Block> path = new List<Block>();

Yeah, the way the course shows it Block is something built into unity and when that didn’t work like the example I tried it how you are showing but still getting the same error.

Solved! I was missing the Block script on each block. Always something simple. Thanks for your help @Martyn_Stewart.