• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Runemark Studio
      Dark Fantasy Environment and Props





    • By bowcox
      Hi guys! 
      I have created a Pong game that has an AI that is almost beatable, changing the speed of the AI can make it ridiculously easy or hard depending on the way you go about it. 
       
      using System.Collections; using System.Collections.Generic; using UnityEngine; public class ComputerMovement : MonoBehaviour { private float speed; private float reAdjustSpeed = 1f; private Rigidbody2D computer2d; public static bool isTwoPlayer; GameObject theBall; Rigidbody2D rb2d; void Start() { computer2d = GetComponent<Rigidbody2D> (); } void FixedUpdate() { if (isTwoPlayer == true) { speed = 5f; if (Input.GetKey (KeyCode.W)) { computer2d.position += Vector2.up * speed * Time.deltaTime; } if (Input.GetKey (KeyCode.S)) { computer2d.position += Vector2.down * speed * Time.deltaTime; } } if (isTwoPlayer == false) { speed = 3f; if (theBall == null) { theBall = GameObject.FindGameObjectWithTag ("Ball"); } rb2d = theBall.GetComponent<Rigidbody2D> (); //Is the ball going left or right if (rb2d.velocity.x > 0) { if (rb2d.velocity.y > 0) { if (rb2d.position.y > computer2d.position.y) { MoveUp (); } if (rb2d.position.y < computer2d.position.y) { MoveDown (); } } if (rb2d.velocity.y < 0) { if (rb2d.position.y > computer2d.position.y) { MoveUp (); } if (rb2d.position.y < computer2d.position.y) { MoveDown (); } } } //Whilst it's not moving at the paddle, let it gain a slight reset by moving with the ball at a slower pace. if (rb2d.velocity.x < 0) { if (computer2d.position.y < 0) { computer2d.position += Vector2.up * reAdjustSpeed * Time.deltaTime; } if (computer2d.position.y > 0) { computer2d.position += Vector2.down * reAdjustSpeed * Time.deltaTime; } } } } void MoveDown() { if (Mathf.Abs(rb2d.velocity.y) > speed) { computer2d.position += Vector2.down * speed * Time.deltaTime; } else { computer2d.position += Vector2.down * speed * Time.deltaTime; } } void MoveUp() { if (Mathf.Abs (rb2d.velocity.y) > speed) { computer2d.position += Vector2.up * speed * Time.deltaTime; } else { computer2d.position += Vector2.up * speed * Time.deltaTime; } } }  
      I have looked up several posts across many different forums in order to create a much better AI. Most of the posts recommend that I use Raycasts to find out exactly where the ball might hit the paddle. I have looked up how to use them and I'm just completely lost, do raycasts consider collisions and go on infinitely or once they hit a wall, that's where it'll end up? Would anyone be able to help me understand raycasts a little better? 
      If you have another solution that enables me to calculate exactly where the ball will end up on the opponents side, I am more than willing to hear it
      Thanks again if you read this!
    • By eldwin11929
      We're looking for a Unity (C#) Programmer for our 2D Project. We're looking for a new lead programmer to continue with an existing project.
       
      Project is an open-world RTS, and is very close to a prototyping (playable) phase. Our existing lead, unfortunately, has no more time for the project, and thus we are in search of a new one who is interested.
       
      Game is purely fantasy based, and we'll be able to give you much more detailed info about the project as we begin to work you into it.
       
      You'll be working with our junior developer, who has been here since the beginning.
       
      Primary skills needed are just being able to work within Unity. But skills within XML are also a plus.
       
      Our list of major goals we'd need you to do is minimal, yet still fairly extensive:
      -Edit our current Pathfinding system to account for a few extra features.
      -Setup our global map system. You’ll be working off an existing random node-map web generator and existing random map generation system and essentially linking the two together. This includes handling random spawns (which has already been semi-setup) unique to each node’s respective map.
      -Further implementation of an existing random spawning algorithm (used to spawn things like enemies randomly across the Map).
      -Making sure to Save and Record all respective aspects of what was mentioned above.
      -Handling our XML database- database is created, but we’ll need to be integrating it. This includes all various things from units to abilities and so forth. Will also need to handle implementing an object’s unique attributes we cannot take care of within XML.
      -Various Content Implementation (to be done once our XML has been integrated).
      -Various Saving and Recording of all respective aspects of the database info mentioned above.
      -Various Performance Enhancements.
      -Potential for various misc things, such as further UI work.
      -Setting up a Menu system.
       
      We have a considerable amount of things done already- however I must warn ahead of time we have quite a bit of unclean code, which may be fairly overwhelming for a new developer on the project.
       
      Let me know your rates per hour, and we'll see if we can work out a good deal between both of us. Royalties are also included.
       
      If interested, send an email to: eldwin11929@yahoo.com
       
      Thanks!
    • By jhocking
      My bestselling and highly recommended Unity book has been fully revised! Unity in Action, Second Edition teaches you to write and deploy games with the Unity game development platform. You'll master the Unity toolset from the ground up, adding the skills you need to go from application coder to game developer.

      Foreword by Jesse Schell, author of The Art of Game Design

      Don't take my word for it being good, look at the sky-high ratings on GoodReads.

      You can order the ebook directly from the publisher's site, or order the book on Amazon to get both the physical book and a coupon to download the ebook!
    • By ThunderTwonk
      Hello everyone, I am working on a game idea and since I am still in the process of learning C# and the features available in unity I was hoping some of you might be able to offer me a little insight on things in general for getting started.
      I guess the basic components of what I'm wanting to create would be a Multi-levels management/city builder/rpg.
      The goal is to provide a framework for players to interact with, build in and affect the world both from a 3rd person action RPG as well as a zoomed out 4x style view (This would be something unlocked through gameplay)
       
      As for my questions go I was wondering if anyone had resources that could help me learn.  I've been on youtube as well as enrolled in an online course for basic unity and C# and will continue those but if anyone has any words of advice, a place that has good information and tutorials etc.
       
      Thanks for your time.
  • Advertisement
  • Advertisement
Sign in to follow this  

Unity Adice for my game project prototype?

This topic is 2032 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement

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

Share this post


Link to post
Share on other sites

[quote name='glhf' timestamp='1349028832' post='4985430']
So i need to make a grid kindof like chess has.

you should use a 2D array for that.[/quote]

What do you mean?



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

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.
[/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='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.

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 sad.png
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='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?

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

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

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

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

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.


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.

Share this post


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


[quote name='glhf' timestamp='1349038666' post='4985483']
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.
[/quote]

Nothing happen when I double click it :(
And if I right click I get this menu without rename option :(
ieibgj.jpg

Share this post


Link to post
Share on other sites
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
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: biggrin.png
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:

x53y28.jpg Edited by glhf

Share this post


Link to post
Share on other sites
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
That is a lot of questions. rather than answering them all, I'll tell you how I would approach this type of game.

  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]
  2. 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.
  3. 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]
  4. 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.
  5. I don't have time to talk about movement now, but I think this should be enough to get you started smile.png

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
Sign in to follow this  

  • Advertisement