Tag Info

New answers tagged

1

Yes, as Arthur Wulf White writes, Breadth First Search is what you want. I wrote a quick & dirty interactive demo showing how BFS expands out from each of your obstacles to assign distances.


2

You can use BFS to accomplish this exactly. You connect all obstacles as nodes (vertices) to the source node. Then simply connect each grid square to the it's neighbors. You don't actually have to do the connecting. You could simply start with all obstacles in the Queue and keep adding neighbors. Breadth-First-Search Time complexity is O ( V + E) so in ...


-4

Math.ceil gives the right feel to snap the blocks to right grids


0

Since all the other answers leave parts of the answer as an assignment to the reader. A traditional Midpoint Circle Algorithm implementation look like the below and only outlines the circle. draw_circle(int x0, int y0, int radius) { int x = radius, y = 0; int radiusError = 1-x; while(x >= y) { set_pixel(x + x0, y + y0); set_pixel(y + ...


2

As was approximately pointed out in comments, the simplest way to do what you're after is to test the center of the square, rather than all of the corners. This isn't exactly equivalent to a majority of the square's area being within your circle, but the latter is a Hard Problem, and it should be close enough for your needs. But note that this doesn't take ...


0

This is untested, but it should get you on the right path. You can replace "Platform" with whatever layer you end up putting your platform cubes in. if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; // An arbitrary distance value. Increase or decrease this value, or you could set to ...


1

I have done this before in a quick and dirty way - using colliders. Put a collider and a script with an OnMouseDown method on the prefab, the method will trigger when the tile is clicked


1

You could "hot spot"-check areas adjacent to the character and immediately begin moving in a free direction if the appropriate movement key is held. For example, if the player is moving right and holds the downward arrow key, they would continue moving right until the below hot spot becomes free. They would then begin moving down. On platforms that ...


5

Without details of your existing algorithm, it's hard to say, but in pretty much any case involving a line over a grid, I've found the answer to be Bresenham's, or a variant thereof. In this case, I'd recommend looking at the Midpoint Circle Algorithm. That can give you a set of outer-bounds tiles, and then just fill it from there.



Top 50 recent answers are included