Jump to content

  • Log In with Google      Sign In   
  • Create Account


Adice for my game project prototype?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 glhf   Banned   -  Reputation: -585

Like
0Likes
Like

Posted 30 September 2012 - 12:13 PM

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.

Sponsor:

#2 VildNinja   Members   -  Reputation: 420

Like
1Likes
Like

Posted 30 September 2012 - 02:34 PM

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

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.

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

you should use a 2D array for that.

IM USING UNITY! and will use c#.

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

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.

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.)

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.

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.

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.

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

maybe its better to not use plan but instead cube?

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.

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.

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).

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?

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 ;)

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?

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.

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

Hope this is usefull

Edited by VildNinja, 30 September 2012 - 02:37 PM.


#3 glhf   Banned   -  Reputation: -585

Like
0Likes
Like

Posted 30 September 2012 - 02:57 PM


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

you should use a 2D array for that.


What do you mean?



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.)

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.

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.

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.


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.



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.

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).

I don't really understand your directions.. sorry Posted Image
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?




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?

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.


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

#4 SimonForsman   Crossbones+   -  Reputation: 5715

Like
2Likes
Like

Posted 01 October 2012 - 01:05 AM



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

you should use a 2D array for that.


What do you mean?


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, 01 October 2012 - 01:07 AM.

I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

#5 VildNinja   Members   -  Reputation: 420

Like
1Likes
Like

Posted 01 October 2012 - 05:29 AM




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

you should use a 2D array for that.


What do you mean?

...
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.

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.

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

Yes you do. If you click the name twice you can rename it.

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.

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]

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?

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.

#6 glhf   Banned   -  Reputation: -585

Like
0Likes
Like

Posted 01 October 2012 - 06:21 AM

Thanks you both!
I think I know now what I need to create map.


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

Yes you do. If you click the name twice you can rename it.


Nothing happen when I double click it :(
And if I right click I get this menu without rename option :(
Posted Image

#7 glhf   Banned   -  Reputation: -585

Like
0Likes
Like

Posted 01 October 2012 - 06:26 AM

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.

#8 glhf   Banned   -  Reputation: -585

Like
0Likes
Like

Posted 01 October 2012 - 09:02 AM

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: Posted Image
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:

Posted Image

Edited by glhf, 01 October 2012 - 09:47 AM.


#9 glhf   Banned   -  Reputation: -585

Like
0Likes
Like

Posted 01 October 2012 - 10:49 AM

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..

#10 VildNinja   Members   -  Reputation: 420

Like
1Likes
Like

Posted 02 October 2012 - 01:37 AM

That is a lot of questions. rather than answering them all, I'll tell you how I would approach this type of game.
  • 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 Posted Image
Edit: split up source block, since it didn't show entire code

Edited by VildNinja, 02 October 2012 - 01:44 AM.


#11 glhf   Banned   -  Reputation: -585

Like
0Likes
Like

Posted 02 October 2012 - 06:19 AM

Awesome!!
thanks so much this makes everything so much easier for me!!
Posted Image




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS