Sign in to follow this  
glhf

Unity Adice for my game project prototype?

Recommended Posts

glhf    585
I have very advanced complex combat system that is too much complex to have on just paper.
I need to prototype it.

So i need to make a grid kindof like chess has.

IM USING UNITY! and will use c#.

I want it to be in 3d too with isometric or 3rd person camera.

But I need help with how i will make the play field.

So how do i make this tile based grid? (guessing its coreect lingo.)

I want each tile to be seen graphically too.

So i need to have a texture for what each tile looks like with a nice border.
then I import the texture to unity and assign it to material.

then i create a plane that i assign this material for.

Then I will have 1 tile so far.

Now what's the best way to create a 3d board tile based grid?

maybe its better to not use plan but instead cube?


ok..
So i want to be able to move my characters from one tile to another by either being able to click on a tile and it moves there or by for example using arrow keys to move one tile ahead.


also, the game i want to make should be multiplayer.
but im newbie at networking.

so i think for the prototype i will just make enemy npc controlled with simple AI?


Also, in unity..
If i have given a name to a file on projects tab like for example a scripts file or a scene file a name..
Is there an easy way to rename it later? because the codes and everything that uses that file will then have the old file name?


Big time thanks to everyone who reply.
This is the best forum.

Share this post


Link to post
Share on other sites
VildNinja    789
[quote name='glhf' timestamp='1349028832' post='4985430']
I have very advanced complex combat system that is too much complex to have on just paper.
I need to prototype it.
[/quote]
Start of with something you can put on paper. Once you got that working you can think about how to make your idea fit on paper. If you really can't I would suggest you to redesign your idea.
[quote name='glhf' timestamp='1349028832' post='4985430']
So i need to make a grid kindof like chess has.
[/quote]
you should use a 2D array for that.
[quote name='glhf' timestamp='1349028832' post='4985430']
IM USING UNITY! and will use c#.

I want it to be in 3d too with isometric or 3rd person camera.
[/quote]
Well first step is to make it top down with no perspective. The difference between that and isometric 3D is one matrix a checkbox and moving the camera. So I see no reason why you should bother with that before you got your grid working.
[quote name='glhf' timestamp='1349028832' post='4985430']
But I need help with how i will make the play field.

So how do i make this tile based grid? (guessing its coreect lingo.)
[/quote]
You shold take the simple soloution and use ONE plane with ONE texture on top of it. This can be limiting if you want randomized maps or animated tiles. But for now you should just make the game work with one static image.
[quote name='glhf' timestamp='1349028832' post='4985430']
I want each tile to be seen graphically too.

So i need to have a texture for what each tile looks like with a nice border.
then I import the texture to unity and assign it to material.

then i create a plane that i assign this material for.

Then I will have 1 tile so far.
[/quote]
You got plenty of coding to do right now, so don't bother with this quite yet. You'll have plenty of time fiddleling with the right approach later on, but don't waste time on this now.
Edit: your ONE texture should contain several tiles.
[quote name='glhf' timestamp='1349028832' post='4985430']
Now what's the best way to create a 3d board tile based grid?

maybe its better to not use plan but instead cube?
[/quote]
Cube or plane really dosn't matter! The best way to create a 3D grid, is to calculate the mapping between mouse clicks and coordinates in your array. Whether you use planes or boxes or teapots for each tile should not be relevant to your logical grid.
[quote name='glhf' timestamp='1349028832' post='4985430']
ok..
So i want to be able to move my characters from one tile to another by either being able to click on a tile and it moves there or by for example using arrow keys to move one tile ahead.
[/quote]
use on variable to hold a refrence to the selected character. If the variable is empty/null assign it with the next clicked character. Else move the characters logical position to the desired tile, and use a coroutine to animate the movement (with slerp or something).
[quote name='glhf' timestamp='1349028832' post='4985430']
also, the game i want to make should be multiplayer.
but im newbie at networking.

so i think for the prototype i will just make enemy npc controlled with simple AI?
[/quote]
Figure out a way two people can play the game on one computer. You can always play with AI, but AI is NOT simple! At least not if your game concept can't be written on paper ;)
[quote name='glhf' timestamp='1349028832' post='4985430']
Also, in unity..
If i have given a name to a file on projects tab like for example a scripts file or a scene file a name..
Is there an easy way to rename it later? because the codes and everything that uses that file will then have the old file name?
[/quote]
Yes Unity takes care of the file name - don't change it from explorer - and Mono Develop or Visual Studio have ways of automatically renaming variables and classes. I think it's on F2 - otherwise just right clcik the variable or class name you want to change, and select rename/refactor in the menu.
[quote name='glhf' timestamp='1349028832' post='4985430']
Big time thanks to everyone who reply.
This is the best forum.
[/quote]
Hope this is usefull Edited by VildNinja

Share this post


Link to post
Share on other sites
glhf    585
[quote name='VildNinja' timestamp='1349037246' post='4985479']
[quote name='glhf' timestamp='1349028832' post='4985430']
So i need to make a grid kindof like chess has.
[/quote]
you should use a 2D array for that.[/quote]

What do you mean?


[quote name='VildNinja' timestamp='1349037246' post='4985479']
[quote name='glhf' timestamp='1349028832' post='4985430']
But I need help with how i will make the play field.

So how do i make this tile based grid? (guessing its coreect lingo.)
[/quote]
You shold take the simple soloution and use ONE plane with ONE texture on top of it. This can be limiting if you want randomized maps or animated tiles. But for now you should just make the game work with one static image.

[quote name='glhf' timestamp='1349028832' post='4985430']
I want each tile to be seen graphically too.

So i need to have a texture for what each tile looks like with a nice border.
then I import the texture to unity and assign it to material.

then i create a plane that i assign this material for.

Then I will have 1 tile so far.
[/quote]
You got plenty of coding to do right now, so don't bother with this quite yet. You'll have plenty of time fiddleling with the right approach later on, but don't waste time on this now.
Edit: your ONE texture should contain several tiles.
[/quote]

True.. this is good advice but is it really so much more work to make many planes next to eachother? isnt it possible in some kind of loop?
I dont know yet how big playing field i want or how big each tile should be... that is another thig i must test in this prototype.. so it must be easy to edit how big map and how big tiles.


[quote name='VildNinja' timestamp='1349037246' post='4985479']
[quote name='glhf' timestamp='1349028832' post='4985430']
ok..
So i want to be able to move my characters from one tile to another by either being able to click on a tile and it moves there or by for example using arrow keys to move one tile ahead.
[/quote]
use on variable to hold a refrence to the selected character. If the variable is empty/null assign it with the next clicked character. Else move the characters logical position to the desired tile, and use a coroutine to animate the movement (with slerp or something).
[/quote]
I don't really understand your directions.. sorry [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img]
I know what variable and reference is but I don't understand... if I am standing on a tile how can i click somewhere so it moves to a nother tile? so if i click somewhere that the game can see i clicked within a grid tile (how can i make a grid? i have board to looks like a grid but its just texture that code doesnt know is a grid?



[quote name='VildNinja' timestamp='1349037246' post='4985479']
[quote name='glhf' timestamp='1349028832' post='4985430']
Also, in unity..
If i have given a name to a file on projects tab like for example a scripts file or a scene file a name..
Is there an easy way to rename it later? because the codes and everything that uses that file will then have the old file name?
[/quote]
Yes Unity takes care of the file name - don't change it from explorer - and Mono Develop or Visual Studio have ways of automatically renaming variables and classes. I think it's on F2 - otherwise just right clcik the variable or class name you want to change, and select rename/refactor in the menu.
[/quote]

I dont get option to rename scene or script files inside from unity projects view.

Share this post


Link to post
Share on other sites
SimonForsman    7642
[quote name='glhf' timestamp='1349038666' post='4985483']
[quote name='VildNinja' timestamp='1349037246' post='4985479']
[quote name='glhf' timestamp='1349028832' post='4985430']
So i need to make a grid kindof like chess has.
[/quote]
you should use a 2D array for that.[/quote]

What do you mean?
[/quote]

Lets see, What i'd do is to:

1) Create a empty game object, name it LevelGrid or something, attach an empty C# script to it, give that script a public member gameobject variable called tile (This can then be set from the editor). create a prefab from the single tile you've created, attach it to the LevelGrids script instance and then use the instantiate method to create new tiles from the scripts init method, set whatever parameters (material, position, size, etc) for each tile as you create it. (can be done in a loop), store the tiles in a array, vector or arraylist. (This works fine for a fairly small grid, if you're making a big grid you might want to merge several tiles into a single object for performance reasons)

2) To detect which tile is clicked do you can use the raycast method in the physics class with the ray you get from: ray = yourCamera.ScreenPointToRay (Input.mousePosition); Make sure your tiles have a collider attached to them.

If you make your grid as one big tile with a grid texture (or if you're merging tiles) you can still use the raycast to get the point on the grid that was clicked on and then divide that by your tile width and height to get the tiles position in a 2D array. Edited by SimonForsman

Share this post


Link to post
Share on other sites
VildNinja    789
[quote name='SimonForsman' timestamp='1349075131' post='4985660']
[quote name='glhf' timestamp='1349038666' post='4985483']
[quote name='VildNinja' timestamp='1349037246' post='4985479']
[quote name='glhf' timestamp='1349028832' post='4985430']
So i need to make a grid kindof like chess has.
[/quote]
you should use a 2D array for that.[/quote]

What do you mean?
[/quote]
...
If you make your grid as one big tile with a grid texture (or if you're merging tiles) you can still use the raycast to get the point on the grid that was clicked on and then divide that by your tile width and height to get the tiles position in a 2D array.
[/quote]
Yes that is the approach I would use. That way you can always decide to remove the texture from the big grid, and add your own cubes or tiles as a graphical overlay. But use the single simple plane to maintain the relation between your 2D array and world/input space.

[quote name='glhf' timestamp='1349038666' post='4985483']
I dont get option to rename scene or script files inside from unity projects view.
[/quote]
Yes you do. If you click the name twice you can rename it.

[quote name='glhf' timestamp='1349038666' post='4985483']
True.. this is good advice but is it really so much more work to make many planes next to eachother? isnt it possible in some kind of loop?
I dont know yet how big playing field i want or how big each tile should be... that is another thig i must test in this prototype.. so it must be easy to edit how big map and how big tiles.
[/quote]
Yes you can easily write two loops that can instantiate a number of tiles in the scene.
[source lang="csharp"]int width = 10;
int height = 10;
Tile[][] tiles = new Tile[width][height];
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
Instantiate(tilePrefab, new Vector3(x, 0, y), Quarternion.identity);
}
}[/source]
[quote name='glhf' timestamp='1349038666' post='4985483']
I don't really understand your directions.. sorry
I know what variable and reference is but I don't understand... if I am standing on a tile how can i click somewhere so it moves to a nother tile? so if i click somewhere that the game can see i clicked within a grid tile (how can i make a grid? i have board to looks like a grid but its just texture that code doesnt know is a grid?
[/quote]
Get a ray from the camera towards the mouse position. Get the x and z coordinates where y hits zero, and cast x and z to integers and plot them into your array (tiles[x][z]). If your characters should walk around like humans, you'll probably need some path finding (A*). If your characters move around like chess pieces you should just use slerp or lerp to move them between the two tiles with a coroutine.

Share this post


Link to post
Share on other sites
glhf    585
Thanks you both!
I think I know now what I need to create map.

[quote name='VildNinja' timestamp='1349090996' post='4985717']
[quote name='glhf' timestamp='1349038666' post='4985483']
I dont get option to rename scene or script files inside from unity projects view.
[/quote]
Yes you do. If you click the name twice you can rename it.
[/quote]

Nothing happen when I double click it :(
And if I right click I get this menu without rename option :(
[img]http://i50.tinypic.com/ieibgj.jpg[/img]

Share this post


Link to post
Share on other sites
glhf    585
Oh, actually..
I wonder how to make the map semi random generated.
SEMI!

So for example.. if i want to have 2 bomb tiles..
But I don't want them spawned same tiles every map.
But I don't want them spawned just anywhere.

How can I do it so the bombs randomly spawn on a few pre determined tiles?

I could also use this for making the map tiles look nicer by for example having those green vegetable veins growing on some of the stone tiles.
They dont affect game except make it look nicer when all tiles dont look the same.

I guess all this is too hard to do with a single plane and texture?
So I need to do this somehow implement this into loop of single cube tiles.

Share this post


Link to post
Share on other sites
glhf    585
I have an idea..
If you don't use any loop tomake a grid of tiles..

you just place them next to eachother manually..
and then you can make a tile "special" so for exampkle:

OOOO
OX OX
OOOO

So you have manually placed those tiles.. they all look the same.. but the X are programmed differently.
The bomb tile will be randomly placed on one of those X tiles.

What do you think about this?

What is best way in your opinion?


edit:
Acutally I could do the same thing if I make it 1 plane and 1 texture too..
so thats probably better..

edit2: [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
How can i draw lines in the plane so i can visually see borders between each grid?


edit3:

here u can see what i done so far:

[img]http://i50.tinypic.com/x53y28.jpg[/img] Edited by glhf

Share this post


Link to post
Share on other sites
glhf    585
Also, one more question about spawning units..

I dowloaded a free character from mixamo..
How do I spawn in to the game?

I placed him on the scene but maybe I shouldn't?

How can I place him with code on a specific tile?
You already explained how I can find tiles on the plane but then how do i place the unit there?

Should I instantiate or something? Or move him there on awake of the game?
Should I have alrady created the character so it's in the hierarchy or just have it in the projects folder?
Because if I don't have it already created in hierarchy (added to the scene so you can see him)..
Then I have to scale him or else he is too small.

I think I can handle the rest after I know how to do all this..
I think I can figure out later after i know how to spawn the unit how to move him around form tile to tile..
but its spawning it that i dont know..

Share this post


Link to post
Share on other sites
VildNinja    789
That is a lot of questions. rather than answering them all, I'll tell you how I would approach this type of game.[list=1]
[*]You need a grid. I would not place the tiles manually, since that would make it difficult to determine which tiles are connected to which. I would start out with a 2D array of Tile, where Tile is an enum of tile types:
Edit: aparently <= breaks the code block. So I use (less or equal)..

[source lang="csharp"]public enum Tile {DIRT, ROCK, WATER, BOMB};

public GameObject dirtPrefab;
public GameObject rockPrefab;
public GameObject waterPrefab;
public GameObject bombPrefab;

Tile[][] map = {
{ DIRT, DIRT, ROCK, DIRT, DIRT },
{ DIRT, DIRT, ROCK, DIRT, DIRT },
{ DIRT, WATER, BOMB, WATER, DIRT },
{ DIRT, DIRT, BOMB, DIRT, DIRT },
{ DIRT, WATER, BOMB, WATER, DIRT },
{ DIRT, DIRT, ROCK, DIRT, DIRT },
{ DIRT, DIRT, ROCK, DIRT, DIRT }
}

int bombLocations = 3;
int bombsToBePlaced = 1;

void Start()
{
for (int x = 0; x < map.Length; x++) {
for (int y = 0; y < map[x].Length; y++) {
switch (map[x][y]) {
case Tile.DIRT:
Instantiate(dirtPrefab, new Vector3(x, 0, y), Quarternion.identity);
break;
case Tile.ROCK:
Instantiate(rockPrefab, new Vector3(x, 0, y), Quarternion.identity);
break;
case Tile.WATER:
Instantiate(waterPrefab, new Vector3(x, 0, y), Quarternion.identity);
break;
case Tile.BOMB:
if (Random.Range(0.001f, bombLocations) (less or equal) bombsToBePlaced)
{
Instantiate(bombPrefab, new Vector3(x, 0, y), Quarternion.identity);
bombsToBePlaced--;
}
else
{
Instantiate(dirtPrefab, new Vector3(x, 0, y), Quarternion.identity);
}
bombLocations--;
break;
}
}
}
}
[/source]
[*]In the editor you should create a Prefab for each tile type you want, and add them to into the script. The prefabs should be no more than 1x1 in x and z. Now you'll get a map where one bomb is randomly placed on one of the three bomb locations.
[*]Next step is to be able to click a tile. Since your tiles are axis aligned on x and z in y = 0, you can easily where the player clicks in your grid:

[source lang="csharp"]if (Input.GetMouseButtonDown(0))
{
Vector3 pos = Camera.main.transform.position;
Vector3 dir = Camera.main.ScreenToWorldPoint(
new Vector3(Input.mousePosition.x, Input.mousePosition.y, 1)) - pos;
float scale = pos.y / dir.y;
Vector3 point = pos - dir * scale;
int x = Mathf.RoundToInt(point.x);
int y = Mathf.RoundToInt(point.z);
print("x: " + x + " y: " + y);
}
[/source]
[*]To import the 3D model you should drag it to the scene, create it as a prefab, scale it to the desired size, apply and remove it from the scene, and finally instanciate it from a script.
[*]I don't have time to talk about movement now, but I think this should be enough to get you started [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/list]
Edit: split up source block, since it didn't show entire code Edited by VildNinja

Share this post


Link to post
Share on other sites
glhf    585
Awesome!!
thanks so much this makes everything so much easier for me!!
[img]http://public.gamedev.net//public/style_emoticons/default/wub.png[/img]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this