isometric view ∨ tile based.

Hi

im very very interested in doing an isometric view game…

( can you say Zaxxon? )

is there any techniques or ideas that people can give on the boards here?

im also interested in using Unity to do tile-based games…I know its a 3d engine - but i think that if used well - you can do some fantastic tile based / isometric old style games mixed with a touch of 3d…maybe Im just an old gamer at heart - but i just dont want to do a first person shooter!

Any help on isometric or tile ideas in Unity?

cheers happy holidays.

Tj

For isometric, use orthographic mode for the camera. There have been quite a few topics on tile-based games which you should be able to find with a search.

–Eric

hey thanks

yea i got it in orthographic…

im talking about the specific techniques to simulate old school isometric.

So i started with a single cube.

Place a camera directly above it

Put camera into orthographic mode

rotated cube 45 on Z

( etc. )

Im still tinkering with it now - hopefully Ill figure out how to set up the camera and world so its isometric like – then I can read up on generating game math towards that end.

cheers,

Tj

ok heres the settings i tweaked out thru some experimenting…

Cube at 0,0,0
cube rotated to 60,0,45
scale to 1,1,1

camera at 0,0, -3
set to orthographic mode
orthographic size 6

this give me what looks like a single isometric cube in center of screen…

Tj

110743--4243--$picture_59_609.png

Im just trying to initiate a discussion here about doing pure isometric view games – in the hopes that some of you experts will help me avoid the pain of mistakes!

So what I’ve figured out so far - is I can make the tiles or game world first in flat view – then attach the set of cubes together using one gameobject - and adjust that into the isometric angle…

So would it be better to just develop and design the whole game in a flat world arrangement - and then just at end move the camera and world into iso perspective?

110744--4244--$picture_61_739.png
110744--4245--$picture_60_520.png

ok

so adding a simple tiny texture* leads to a nice q-bert like cube world area. Im still wondering what the ‘better’ way to do this is? Im wondering if I should use tile generative code…hmm.

(64 x 64 is what i used…? or should i make it small as possible 4x4? 2x2? its just for the simple edge detail )

110748--4246--$picture_62_866.png

Unfortunately I cannot offer any advice, as I am an amateur in this area, but I am very interested in your progress/discovery and project. Since I also want to so something like this (that old school gamer blood), anything I find on the forum or elsewhere I’ll try to forward to you.

Watch out that if you simply fill the screen with individual tiles attached to GameObjects, you’ll probably end up with a very low frame rate due to the large number of individual draw calls. You might be better off modelling and manually texturing larger chunks of scenery, or at least using the CombineChildren script to merge sections of your scene together. You can still use an isometric view with these techniques, of course.

In this prototype, I built the scenery as a single mesh in my modelling app, then applied a different section of a texture containing each of the tile images to each face.

aha

i was hoping some experts would pipe in there! Great looking retro game - love the pixel art look!

yea Im looking at old tiling games code that would iterate and destroy tiles as needed - and perhaps it needs to be a ‘prefab’ ? then it might lower the calls and memory?

I see what you mean about making a bigger piece with just texture mapping - ill try that too.

cheers

Tj

You should look into using multidimensional arrays in C#. Then on top of that create a class that represents a “tile” in the world. Let’s call this class “Tile”. All the tile class does is hold the Vector Position of that tile in the world. It could probably hold a texture as well if you wanted it to.

So for instance you could have 1 mesh with different textures like NCarter mentioned.

So for example, if you had a world of what you wanted to be 100 x 100 tiles (x, y) then the code would be like this:

int tileWidth = 25; // width of each tile’s X
int tileHeight = 25; // width of each tile’s Y

int tileMapWidth = 100; // # of X tiles in array
int tileMapHeight = 100; // # of Y tiles in array

Tile[,] tileArray = new Tile[100,100];

for (int x = 0; x < tileMapWidth; x++)
{
for (int y = 0; y < tileMapHeight; y++)
{
tileArray[x,y] = new Tile{ Position = new Vector3(x * tileWidth, y * tileHeight, z}
}
}

This is a fast way to dynamically create a tile map. I’m sure there are better ways to do this, I’m still a newbie so I’m still learning as I go.

Then if you need to move something around the tiles in the world, you keep track of where it is current (x y values of the current tile it is) and then you get it’s destination (x y values of the new tile). You get the Vector of both by saying tileArray[x,y].Position. You can do that because you have a Tile object in each position in the array that has Position as one of it’s properties.

Once you have those two vectors you can implement a state machine on that object to go from “Idle” to “Moving” and move the object to those tiles. While it’s in “Moving” state, you don’t accept any input to it. Set the object to have a speed property and multiply that by the delta or elapsed time to move between the tiles. Every update, check if you’re there yet, and if you’re not keep moving. If you’re there set the state back to “Idle”.

yes

this is the kind of discussion i was hoping to get going. :slight_smile:

thanks for that one! - Im digging thru some old tiling code too and i was just thinking to use vectors stored in arrays.

merry xmas!

Tj

so i see that all scripts must be attached to something in order to execute in the game – now Im starting with a blank game object - and attaching the tile-building code here…is that typical for a set up? Empty game object to hold scripts that are not particular to individual objects? Does it really matter? Is there a pattern that is used by more seasoned developers?

It looks like also that one should use built-in arrays for this task…

( just talking out loud - so that the experts around here will kick me when they hear me traveling down the wrong roads…ha. )

merry xmas!

Tj

Here’s an editor script (from the wiki) that you should be able to use to snap objects to a grid, if you were going to be laying out blocks by hand:

http://www.unifycommunity.com/wiki/index.php?title=SnapToGrid

I’ve never used it though.

hey thanks for that! Ill look into that as well…

Ive gotten around to partially generating a sequence of cubes thru some borrowed bits and pieces Ive found in the manuals etc - and this has helped me learn Unity a bit more…

Now Ive generated some cubes -but they are all individually floating objects – and Id like to have instead added them into an encapsulating object called “tiles” - that I can do one simple transformation and have it affect all. But i have not been able to get .AddComponent( ) to work properly.

How would one generate these but have them all properly placed inside one object for overall control and manipulation?

// Instantiates a prefab in a grid

var cube0 : Transform;

function BuildMap (map) {

    for (var y = -(gridY); y < gridY; y++) {
        for (var x= -(gridX);x<gridX;x++) {
            var pos = Vector3 (x, 0, y) * spacing;
            Instantiate(cube0, pos, Quaternion.identity);
            
        }
    }
}

Ah

I think I want to make the instantiated new cubes ‘children’ of some main gameObject…

how to do this?

TJ

to make an object child of another, do:

childGameObject.transform.parent = parentGameObject.transform;

in your case, if you have the script attached to the parent object, just do:

// instantiate prefab
var go : GameObject = Instantiate(cube0, pos, Quaternion.identity);

// set the new object to be child of the object this script is attached to
go.transform.parent = transform;

as somebody mentioned before, you’ll probably want to look at combining the meshes of the generated cubes, otherwise performance will suffer greatly. it’s a bit of a more advanced topic, so don’t worry too much about it now while learning, but do keep it in mind.

good luck on you learning project, i love isometric games too :smile: i did a quick test some time ago, though it’s only isometric “in spirit”. i’d love to finish it someday: http://www.joaquinestrago.com/unity-tests/beatemup.html

cheers!

haha

man that game is funny…its like GTA!! I was doing illegal things the moment it started!

thanks for that info – yea I have a blank gameObject in the scene and I was hoping to just find it - and attach these tiles to it.

and yes - I understand this isnt the most effective use of Unitys engine - but its more a learning exercise. I dont plan on making a huge world but just a small area that I can programatically manipulate. I can see how its smarter to make one giant model and then use a texture map for some reasons - but then that brings up the question what if you wanted each tile to animate or be specialized? ah - I suppose you can call a ‘single’ tile and have it just appear where you need it - instead of making the whole thing be individual tiles…ok i see.

Ill keep tinkering!

thanks again.

TJ

Just wanted to tell you to please keep posting your progress. This is a really fun and interesting thread to watch as another Unity novice.

hey!

well this might help - I found some excellent tile based tutorials for flash…and I think it would be great to have this stuff translated into Unity compatible ideas.

Heres the tutorial Im attempting to go thru and re-jig around.

Ive gotten to generating the map array like this:

    // build myMapArray
    myMapArray = new Array (
    					[1,1,1,1,1,1,1,1],
						[1,0,0,0,0,0,0,1],
						[1,0,0,0,0,0,0,1],
						[1,0,0,0,0,0,1,1],
						[1,0,0,0,0,0,0,0],
						[1,1,1,1,1,1,1,1]);

I then pass this array into
a map building function ( not done yet!! watch the sloppy code! )

like this:

BuildMap(myMapArray);

and notice all the casting I had to do because Im tripping up on the strict typing rules…?

// Instantiates a prefab in a grid

function BuildMap (map : Array) {
	print("The map: " + map);
	var mapWidth : int;
	var mapHeight : int;
	mapWidth = map.length;
	print("The array width: " + mapWidth);
 	mapHeight = (Array(map[0]).length);  // whats up with this casting? doesnt map[0].length just return an int?
 	print("The map height: " + mapHeight);
 	
    for (var y = -(mapHeight); y < mapHeight; y++) {
        for (var x= -(mapWidth);x<mapWidth;x++) {
            var pos = Vector3 (x, 0, y) * spacing;
            var newCube : GameObject = Instantiate(cube0, pos, Quaternion.identity);
            newCube.transform.parent = GameObject.Find("Tiles").transform;
        }
    }
}

So Im still working on this part - but now i got it to spew out a single cube for each map point…

    for (var y = 0; y < mapHeight; y++) {
        for (var x = 0; x<mapWidth; x++) {
            var pos = Vector3 (x, 0, y) * spacing;
            var newCube : GameObject = Instantiate(cube0, pos, Quaternion.identity);
            newCube.transform.parent = GameObject.Find("Tiles").transform;
        }
    }
}

now I need to get it to recognize the array value - and then place a white or black cube based on the type of tile its representing.

110899--4251--$picture_65_934.png