assign variable to grid position

Hello,

I’m trying to create a 3d grid based movement system. id like to build a scene full of objects with various grid positions and report their identity to some kinda central array (list? i dunno).

So if i put a ‘wall’ cube at position (1,1,1) I’d like it to report to somewhere that level_array(1,1,1) = “wall”; or better yet, store its gameObject to that address.

when the player wants to move into position (1,1,1) Id like to do a quick check, “does level_array(1,1,1) contain a wall? if not, you can move there”

Any tips on where i should look to figure this out? useful examples, documentation, theory? I’m a little stuck on even what to google. if you couldn’t tell I’m quite new to this.

You are probably looking for multi dimensional arrays in C#.

It depends on what you want to do. Multidimensional arrays are certainly one option, but they can be quite limited depending on what you want from your game.

Will your world be a fixed size or do you want it to grow indefinitely as the player moves? A multidimensional array setup might struggle if you need the world to grow dynamically. If not, it’s probably the simplest and fastest way to do things.