Tag Info

New answers tagged

1

You could make the player move two spaces if they move up, down, left or right, and only one diagonally. It wouldn't completely even it out, but it would be much closer.


6

To have diagonal and orthogonal movement reveal approximately the same area, you need two things (each of which, alone, has already been suggested in another answer or comment): Approximately circular view range: On its own, this won't give exactly the same revealed area for both types of movement. For example, in the image above, orthogonal movement ...


0

You can resolve this by: Finding the bounding box of that shape. Increasing it's size by 1 in each direction. Iterating over the frame of the new slightly enlarged bounding box and applying flood-fill. If there are any tiles that you did not mark with flood-fill that are not on that chain then they are enclosed. I suppose that by your definition if there ...


2

As an alternative to a more complex field of view (which as discussed above adds its own problems because of the constraints of a grid-based layout) you could try to emulate the effect of movement in a game that isn't based on a discreet grid. Where free movement is possible a diagonal move of one unit would be exactly that, not the ~1.41 units of movement ...


4

How about, rather than having a fixed viewing range, have the player's visibility area depend upon what direction the player was facing, as well as perhaps the direction the player faced in the last few turns (a player who was moving north might be able to immediately take a step south, but might take a few turns to get maximum viewing distance in that ...


42

Dungeons and Dragons 3.5 (pen-and-paper RPG) has a solution used for both movement and grid-based radius calculations: diagonal movement costs 1.5 what orthogonal costs. Since the diagonal of a unit square is approximately 1.414, 1.5 is pretty close. Because D&D 3.5 only supports integer movement, the way this is actually calculated is that orthogonal ...


8

Since you are using a grid and know which direction the user is proceeding there is nothing constraining you from adapting the prior answer and using a different fields of view depending on the direction. For example you could extended the field to include the corners when you travel in cardinal directions and shrink it down two squares on each end in your ...


41

You need to change the shape of the field of view. So that when you move in any direction, the same number of new squares become visible. Here is one possibility:


0

Your intuition is right, assuming that the chain ends as soon as the user tries to select a tile they have already selected. In that case, the shape in general looks like a lasso, in your picture (4). If they can keep swiping, then they can draw many loops, and things get more complicated. What you want to do is answer the points-in-polygon question. ...


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