• 11
• 9
• 10
• 9
• 10
• ### Similar Content

• By juicyz
Hey all,
I've been slowly working on my game called AotW for a while now.  I have come to the conclusions that it would be nice to cooperate with 1 or 2 others to help finish it.  Ive been trying to keep my GDD up to date with my ideas and development so that would give a better overview of the game when the time comes.  Currently I have a basic skeleton of the RPG elements needed but everything can still be discussed and talked about and we can transform my idea to something the group likes.
The premise of the game is a Diablo-like procedurally generated map with RPG elements that include sockets, inventory, classes, abilities, crafting, loot, items, sockets, and enchanting.  This will be done in a 2D iso view as I can't do 3D art and I enjoy 2D games a lot.

I don't plan on releasing this as this is more of a hobby project for me and I have a full-time job.  Though I'd like to start putting more hours into development and having others definitely will be motivation.  I also want to be able to say I have finally "finished" a game idea to some degree.  If the time comes and we want to release it, then we can go ahead and do so but that's not my purpose or plan.

Discord:
Juicyz#3683

Thanks,
Juicyz

• Hi, I've been working on this issue for a while and haven't yet found an answer.
Does anyone know the best way to convert unity's LAT & LONG into a vector 3 position that I could use in a virtual world (if it's even possible).

• I am taking an absolute beginner's game development course and we have just finished game jams in small groups. Our current assignment is to get feedback from people working in any aspect of game development. I would very much appreciate any feedback! The game is up on itchi.io (sound warning) https://wobbegong.itch.io/zombie-shooter It's essentially a very basic PvE.
I also have some things I'm wondering about, but you don't necessarily have to answer these.
1. Do you have any tips on working with physics? My group wrestled a bit with Rigidbody physics not totally working the way we wanted to -- jumping ended up kind of floaty and inclines seem to mess up movement. Alternatively... how can I build terrains with depth that won't result in wonky physics?
2. How can I keep up the level of challenge in an interesting way as the player progresses through the waves?
3. What are some of your personal guidelines for creating title screens?
Thank you very much in advance!

• I'm having a weird issue with detecting a collision. I've tried everything I could find online but nothing seems to work. I have a brick object. It has a 2D Collider attached and I have also attached a 2D Rigidbody on it. I also have an EndScreen 2D Collider. The EndScreen 2D collider is tagged with "EndScreen". I am trying to detect when a brick collides with the end screen collider and simply print "game over" in the console.
This is my current code for this part of the program, it is attached to the bricks:
void OnCollisionEnter (Collision2D collision) { if (collision.gameObject.tag == "EndScreen") { Debug.Log("Game over"); } } Several things have happened depending on the set up. If I have the rigidbody 2D set as static, my ball object can still collide with the bricks, but I get no Log message. If I set it to Kinematic or Dynamic, I get absolutely no interaction between the ball and the bricks, and nothing when the bricks pass through the collider. I have tried to set the collider to a trigger and use OnTriggerEnter2D, no change. I have tried to put the rigidbody on the EndScreen object and tried to set it's body type to all 3 settings, no change. The only thing I can think of that I have not done is put the script on the EndScreen object and switch the tag to the bricks. The reason I have not done this is because I will have several types of bricks, some of which will have different tags.

Please tell me somebody can see what I'm doing wrong here, because I'm losing my mind over something I feel should be ridiculously simple. Thanks.

# Unity Need help with pathfinding C#

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

## Recommended Posts

Hey, im making pathfinding for c# and understand the algorithm but the code is confusing.  How would i be able to devide the amount of set space and make rectangles using graphics that are 50 , 50 pixels and fill the area if the area is a multiple of 50? Im not using XNA or Unity.

##### Share on other sites

Also preferably a list of the rectangles name in listing them like "myTile1" "myTile2" "myTile3" ect.

##### Share on other sites

It is hard to determine what you mean in the original post

Hey, im making pathfinding for c# and understand the algorithm but the code is confusing.  How would i be able to devide the amount of set space and make rectangles using graphics that are 50 , 50 pixels and fill the area if the area is a multiple of 50? Im not using XNA or Unity.

Do you mean you are doing a 2D game which is on a grid or that is 50*50 pixels in size? Or is this a 3D render and you want to overlay a grid on top that you will path find over?

If your game is 2D grid based they you should not worry about the render size of each tile at all, just the coordinates, as the render size of the tile is UI based and all the path finder should care about is the tile you are currently evaluating etc.

My Path finder code has no concept about the map/game world or whatever it is navigating over, instead it take the follow arguments, The bounding size of the map, so X,Y,W,H along with a Func<Vector, bool> which the path finder uses to decide if the vector location is a valid move. The caller supplies the function and this is what decouples the route finder from the map. If you can think about it this way it will help split what is A* code away from map and render based stuff which just don't matter :)

Also preferably a list of the rectangles name in listing them like "myTile1" "myTile2" "myTile3" ect.

If you have a grid why would you want to "name" of the tile instead of its coordinates? The only logical reason for the names would be you have the tiles in a map by name and you want to use that for lookup, this is unwise as the cost of string based lookups with a large grid could get costly for something like path finding.

##### Share on other sites

Generally the navigation mesh (3D) or navigation grid (2D) is created along with the art.

Often it will encode additional information, such as the type of motion to use on the area (walk, swim, climb, crawl, slippery, etc) and sometimes different areas can be traversed at different times (can swim after getting flippers, can walk on quicksand after getting special boots, etc).

WozNZ basically covered the rest.

##### Share on other sites

Guys, All i need is a algorithm to make 50, 50 width and height rectangles that fit into a 1000 , 1000 pixel form. i want to name the tiles so that in different locations it could set a boolean for the tile to be unable to pass or not. It is a 2d game. No xna or Unity. all i want is to make multiple rectangles like new Rectangle blah (blah blah) exept without me having to do it a bunch of times.

##### Share on other sites

Surely all you need is two for() loops inside each other then, from 0 to your world size / 20?

##### Share on other sites

Please be more descriptive. Im trying to make it so there is 44 tiles (i did the math) each 50 by 50 pixels. I want them all named from 1 to 44 using possibly a  loop. Im not sure how loops (or any commands beside manually naming it like (new Rectange recty;)) can be used to name things but if you can find that out it will be extremely helpful.

##### Share on other sites

Not sure where you're getting 44 tiles from.... a 1000X1000 pixel area would hold 400 50X50 pixel rects

If you're asking to name the variable itself myTile1, myTile2 etc, like:

var myTile1 = new Rectangle(...);

Then no this is not possible in any reasonable way and is really a horrible idea. Instead, you should have something like a 2d array of Rectangles accessed by their grid location:

var width = worldSizeX / tileSizeX;

var height = worldSizeY / tileSizeY;

var grid = new Rectangle[width, height]();

And then use something like this to build the array:

for (var j = 0; j < height; j++)

{

for (var i = 0; i < width; i++)

{

grid[i,j] = new Rectangle(i * tileSizeX, j * tileSizeY, tileSizeX, tileSizeY);

}

}

Edited by jdean300

##### Share on other sites

Im not sure how loops (or any commands beside manually naming it like (new Rectange recty;)) can be used to name things but if you can find that out it will be extremely helpful.

I'm not sure why you're jumping in to pathfinding already without having the fundamentals down already. You MUST understand the basic principles of programming, or else you'll ask extremely weird questions like this.

You can't make a loop to generate multiple *variables* such as "Rectangle myRect1; Rectangle myRect2;" without using code generation, and you should NEVER use code generation for this kind of problem. You can't do ANYTHING to make new variables in C# at runtime unless you're compiling code on the fly, which you shouldn't do. You can only set the values of existing variables and use collections such as arrays, lists, etc.

In this case you need to use an array. Here is an example of a 2D array of Rectangles in a C# WinForms app:

Rectangle[,] grid = new Rectangle[20,20];

for (int y=0; y<20; ++y)
{
for (int x=0; x<20; ++x)
{
grid[x,y] = new Rectangle(x * 50, y * 50, 50, 50);
}
}

And like jdean300 said, where did you get 44 tiles? That isn't even a square number. (1000 / 50) per axis is 20, squared is 400. Edited by Nypyren

##### Share on other sites

For the OP, you are trying to connect the appearance of the tile to deep into your code.

public class Tile

{

public string Name { get; set; }

// some other properties in you tile here

}

Now you can store your map as follows

var Map = new Tile[20, 20];

And loop through the grid adding the tiles using whatever map builder you want.

NOTE [20, 20] is based in 1000*1000 pixels divided by your 50*50 tiles

Notice how there is no notion of the size of the tiles above, that is all decoupled and is the responsibility of the render engine which could use Tile.Name to determine the graphic representation for the tile.  This way the tiles could be 10*10 or 200*200 on screen or even ACSII text display, it does not matter.

You have to decouple in this way, think what happens if your game is played on a 4K monitor, your 1000*1000 pixel map is now tiny. The pixel size of tiles should never impact the game engine logic or you will find yourself in a world of pain later down the line. The reality is that if you have grid based movement in your game you should be able to write the engine to control the game that is self contained and has no concept about how input is received or how the game is displayed, they just do not matter to the game logic

You need to step back and think about what you are trying to do and possibly take some time out and learn some more about code, abstraction and separation of interests before you revisit your game code.

Edited by WozNZ