3D TILE MAPS for AI .

On following Ben Northcott's recomondations about tile maps I followed some links. It led me to an article on gamasultra.com about the "a star" pathfinding algorhythmn. All of the examples led back to a strange interface - a tilemap editor. In typical Ben style... he mentioned in a conversation we had, "that he wished he had the time to make one of these tilemap editors". Clearly he has already...cause the guy is a humble genius. So I figured that he was trying to tell me without belittling me about the relationship between AI and tilemaps. I had never seen one of these before... well I lie... I had, I just didn't know what they did when i saw em in the past. I found a good one at setpixel.com. also found others here and there afterward.

To the best of my current knowledge.......

Theres a similarity between 2d maps and 3d map implentations. If the floor had mild changes in height it wouldnt be an issue. If the floor had serious height you could either deem it unwalkable / preferably not walkable or even slow the speed/ animation based on either the region, or angle of the face below the enemy when traverseing it, if the enemy had to move there.

A 3D TILEMAP CONSIDERATION

This center point of a model without tweaking, is at vector(0,0,0). when you move a model in director the vector position is tracked eg. a model whose pivot point is at vector(0,0,0) . If you move the model -> translate(10,0,0). then the models centre point (worldposition) would be (10,0,0). this makes it easy to make a tilemap in 3d as the models position is recorded for you.

I explain this cause the astar scripts spit out a path array eg;
astarPath = [[1,2],[[2,1],[3,1]...etc]

For the purposes of a 3d tilemap Im considering the first value to be an "X" vector value and the second to be a "Z" vector value. As for the "Y" vector value? I will just say its at floor height. In this case it equals zero.

VectorPath = [[vector(100,0,200)],[vector(200,0,100)],[vector(300,0,100)]...etc]

the "astarPath" values are multiplied by the width and position of your tile to make the "VectorPath" values.

Unfortunately I dont know 2D gaming yet...I need to figure out all this stuff on a 2d scale to put into effect all the 2d lingo AI implementations I have found. Over Christmas I'll do it, If I can borrow a computer in NZ.

Considering an example....

For a tile map that is 10 by 10 (100 models ) you could make them in modeler if you wanted. In my case, because im trying to make file size as small as possible. I use an API ( Application Programming Interface ) and some code.

EG: from a parent script

THIS CREATES A 100 MODEL, 10 by 10 GRID

on new me
me.createMap --call the handler that makes the tile map
return me

on createMap me
repeat with TX = 1 to 10
repeat with TY = 1 to 10

-- call the API "create" 100 times
-- give it the name "Obj(1,1) , "Obj(1,2)" , "Obj(1,3)" ....."Obj(10,10)"
-- each time moving the tile by multiplying it by the TX / TYvalue eg: vector(100,0,100) ,vector(100,0,200)


me.create("Obj"&"("&TX&","&TY&")",100,100,texmem, vector(TX*100,0,TY*100))
end if
end repeat
end repeat
end

on create me, tileName, L, W, whichtexture,trans -- an API that creates plane primitives
Res = scene.newmodelresource(tileName, #plane)
Res.length=L
Res.width=W
Obj = scene.newmodel(tileName,Res)
Shd = scene.newshader(tileName, #standard)
Shd.texture = whichTexture
Obj.shaderlist = Shd
Obj.rotate(0,90,0)
obj.transform.position.x = trans.x
obj.transform.position.z = trans.z
Obj.rotate(90,0,0)
Shd.flat = 1
end

in the message window;

-- Welcome To Director--

put scene.model("Obj(6,8)").transform.position
--vector( 600, 0, 800)
-- when translating I consider it to be an astarPath value of [6,8]

SOMEBODY ELSES TILEMAP EDITOR

Here is an example of a tile map maker that was made by EDIOS interactive for the famous PS1 game Tomb Raider 1.

In this paticular scene - which I know from playing...the central black dot represents a water world. The others represent hallways to other rooms. I would imagine that if a particular flag = true then the engine would load that room of tiles. Also worth noting is that each of these squares would have a single vector point for AI which a pathfinding engine could use until the enemy asking - got within a certian distance of the character. The enemy would then attack straight to the characters vector position - unless of course one of the positions between here and there was the water world or some other unwalkable terrain. This would be the point at which the enemy would "a* pathfind" again or just start to wander again If the character was deemed un-attackable.

TEXTURES AND TILE MAPS

A great reason to use tile maps other than for AI, is for file size! - when games started VRAM was minimal so instances of parts of worlds got duplicated from single tiles to make large worlds (see - nonoche.com for example) today, most computers have from 16mb VRAM to 128mb VRAM so this is a smaller issue - however if you are gonna download a game tileing would make perfect sense. Why not repeat similar items. You would only have to download a texture that could be used hundreds of times once instead of downloading one massive file. Anyways gameplay is probably the most important element of a game. Imean Tomb Raider looks like crap these days but I still clock it every 6 months.

check out some links Ive found about tile maps;

http://www.nonoche.com/imaging/en/index.html

http://www.director-online.com/buildArticle.php?id=841

http://www.gamedev.net/reference/articles/article934.asp

http://www.macromedia.com/devnet/mx/director/articles/maze_magic.html