Hot answers tagged

155 votes

How can I clean up excessive player-created rubble?

Figure out your bottleneck A few hundred moving objects should not be a problem. However, a few hundred colliding objects might be. It will take some testing, yet I believe the bottleneck you have ...
Theraot's user avatar
  • 26.2k
73 votes
Accepted

Are all games made by drawing each frame?

Very old games used a technique where only those parts of a frame are redrawn that changed on that frame. What I can remember, the game "Little Big Adventure" uses this technique (1994). But you can ...
Arne's user avatar
  • 977
72 votes
Accepted

How can I clean up excessive player-created rubble?

First of all, that game mechanic looks like it could be super fun, so congrats on thinking of it! Here are two simple solutions that could be used independently or together to solve this particular ...
Chase Sandmann's user avatar
66 votes

What is the term for a 3x3 tile set used to create larger areas?

I'd disagree with the accepted answer here. I'd call this an autotile, and not a 9-slice "9-Slice" (or 9-patch) is usually used to refer to a system where the content creator slices the image along ...
DMGregory's user avatar
  • 134k
50 votes
Accepted

How do we convey scale in 2D games?

Large, open areas do not work very well in top-down 2d. Putting the player in such an area just disorients them. It is much better to use more complex areas which limit the way the player can navigate....
Philipp's user avatar
  • 119k
49 votes
Accepted

How can I procedurally render irregularly shaped health bars?

There is a very simple way achieving this with shaders, you need three* textures: empty health bar, health bar texture and mask with gradient of health distribution with one extreme(e.g. darkest not ...
wondra's user avatar
  • 4,920
42 votes
Accepted

How to animate abstract 2d top down water texture?

A common way this is done is using an indirect texture lookup in the shader to distort the display texture: Here I'm using a texture with some low-frequency colour noise (tiling smooth blobs of ...
DMGregory's user avatar
  • 134k
39 votes
Accepted

What is the term for a 3x3 tile set used to create larger areas?

A name that will give you actual results in Google is 9-slice. Another way to call it and ask Google about it is 9-patch. As per this chat discussion, 9-pane seems to also be used, but the almighty ...
Vaillancourt's user avatar
  • 16.3k
38 votes

How can I make user-friendly polar coordinate movement around a circle?

My first suggestion would be to just stick with A = Counter-clockwise and D = Clockwise movement. It is not very confusing and is pretty much the "standard" (i.e. most common) choice when it comes to ...
Charanor's user avatar
  • 7,840
36 votes
Accepted

Combinations for tiling two textures together

There's a solid overview of different popular tile combination patterns put together by Boris the Brave, building on some earlier work by Sean Howard. I'll briefly summarize the main categories these ...
DMGregory's user avatar
  • 134k
35 votes

How can I procedurally render irregularly shaped health bars?

Implemented mathematically, as a pixel shader: On the CPU, calculate HealthDirection and its' dot product with V2 On the GPU, calculate a normalized direction away from the centerpoint for each ...
Jon's user avatar
  • 3,694
34 votes
Accepted

How can I detect the player being crushed in a 2D platformer?

I think you'll have to take the box's movement into consideration. That is, only crush if the box is moving towards the player. This is similar to other problems in platformers, where the movement is ...
congusbongus's user avatar
  • 14.8k
34 votes
Accepted

What is a 'Mask' in Game development?

Conceptually, masking involves selectively ignoring something, usually to isolate something else. The two main uses I've familiar with are: Masking data such as bit fields or flags for bitwise ...
Pikalek's user avatar
  • 12.2k
30 votes

Enemy is losing 2 health instead of 1

I think you have twice as many components as you need here. While I'm generally in favour of small single-purpose classes, "have a health value" is so tightly linked to "modify health ...
DMGregory's user avatar
  • 134k
30 votes
Accepted

How to make the player feel like giving up?

Minor spoilers follow for Journey and Nier Automata. Both of these games include scenes where the player is meant to feel extremely discouraged. The way they both sell this in the game mechanics is by ...
DMGregory's user avatar
  • 134k
29 votes
Accepted

What is the size limit to the Unity 2017.2 Tilemap?

Your RAM is your limit. The following tests were performed on a system with these specs: Intel i5-6600 16 GB RAM NVIDIA GeForce GTX 1070 Windows 7 Home Premium Here is a script I ran which grows a ...
Philipp's user avatar
  • 119k
28 votes

How can I shorten the length of time spent on finding a path using my A* pathfinding code?

Let's start with some general C# optimization advice: Avoid heap allocations in your hot path. That means anywhere you have new Foo(...) where ...
DMGregory's user avatar
  • 134k
27 votes

Ways to draw tracks on 4-connected grid

This is Matt, the creator of Trainyard. @DMGregory summoned me here! :) It sounds like you're working through the same issues I had to deal with. It's a tricky problem where there isn't necessarily a ...
Matt Rix's user avatar
  • 371
26 votes

Non-integer speed values - is there a cleaner way to do this?

There is a simple way to do exactly what you want. In addition to a float velocity you'll need to have a second float variable ...
HolyBlackCat's user avatar
  • 2,006
26 votes
Accepted

How can I implement persistent state for objects defined in a level?

I think not overthinking this issue will give the best results so I would just implement a simple key-value saving system into your game that you store along your other save data and then load on-...
Charanor's user avatar
  • 7,840
24 votes
Accepted

How can I adapt A* pathfinding to work with platformers?

You don't need to adapt A* at all. The only consideration is where you put your nodes and how you connect them. The linked article seems to convert from a platformer-friendly model to a grid based ...
Liam Lime's user avatar
  • 728
24 votes

How can I help my unpaid 2D and 3D artists improve their portfolio?

You got to find a way to pay your artists. Currently they don't really get anything out of the work on your project. Even if your project would demand artwork on a level of polishing that's good ...
Philipp's user avatar
  • 119k
22 votes

Scale camera to fit screen size unity

You can adjust the camera's height so it scales with the width of the screen like so: (Place this script on your Camera object) ...
DMGregory's user avatar
  • 134k
21 votes
Accepted

Scaling my pixel art platformer from 720p to 1080p

For anyone wondering why this is an issue for pixel art, here's a quick example using a scene from Super Mario World: If we just scale a pixel art game from 720 to 1080 at runtime (the way a typical ...
DMGregory's user avatar
  • 134k
20 votes

How can I rotate pixel art sprites without the aesthetics getting ruined?

Have a look at RotSprite. RotSprite is a scaling and rotation algorithm for sprites developed by Xenowhirl. It produces far fewer artifacts than nearest-neighbor rotation algorithms, and like EPX, it ...
Rudey's user avatar
  • 453
20 votes
Accepted

Understanding pixel art in Unity 2d

Summarizing the points above, what matters for two pieces of pixel art to match is that their pixel density (texels per screen area / world unit) is the same. Using some sprites from Stardew Valley ...
DMGregory's user avatar
  • 134k
19 votes

How do we convey scale in 2D games?

I believe the answer lies in 2.5D If your game is a 2D sidescroller, then you may rely on parallax scrolling, shadows and lighting to convey size and scale better. If your game is a 2D topdown or ...
Natalo77's user avatar
  • 679
18 votes
Accepted

What are good algorithms to generate borders / state areas on 2d star maps?

I think the Voronoi idea is a good one. Each star becomes a seed point for Voronoi, and then the Voronoi regions show the areas owned by each faction. However, there are some changes that will make it ...
amitp's user avatar
  • 6,036
17 votes
Accepted

How can I rotate pixel art sprites without the aesthetics getting ruined?

Automatic rotation of pixel art by other angles than 90° usually goes wrong. If you want to maintain the pixel-art aesthetics you usually won't get around redrawing your art in each angle. If you use ...
Philipp's user avatar
  • 119k
17 votes
Accepted

Invert the colour of pixels where 1 bit sprites are overlapping

We can do this by making a custom version of the standard sprite shader (so it still does everything the one you're used to can do), and modifying its blending operation. Start by going to the Unity ...
DMGregory's user avatar
  • 134k

Only top scored, non community-wiki answers of a minimum length are eligible