Hot answers tagged

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
  • 133k
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
  • 133k
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
17 votes

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

I'll skip the mandatory part talking about payment. I get it. I've worked on a game for free for years because it's a passion. I assume the same is true for these people as well, to an extent, but ...
Onyz's user avatar
  • 271
6 votes

How to make the player feel like giving up?

I'd like to add Celeste to this as an example. Some of the levels there can be brutal, but there is little to no death penalty and you're back where you were a moment ago. This way, you'll have to ...
Steven's user avatar
  • 881
5 votes
Accepted

Would it be possible to make a Game Genie like program in Javascript?

What exactly do you want to replicate from a Game Genie code? The format of the original can be found in the docs here, but fundamentally they identified a part of the memory to change and the type of ...
Basic's user avatar
  • 1,242
4 votes

Increment score when player touches a coin's Area2D

You should not need any more scenes than you have. I'm going to suggest to do this with a Signal Bus, although it is not the only approach. Mainly you need to do this: Create an autoload with an ...
Theraot's user avatar
  • 26.2k
4 votes
Accepted

Avoiding nausea when spinning

The best solution can be determined on how your game "feels" while playing it, but here's a few suggestions that you can consider: Smooth Camera Sure the ship needs to always point at the ...
Tom Tsagkatos's user avatar
4 votes

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

It sounds like your root problem is wanting to keep your team members on board. As with all volunteer-based projects, it's important to be mindful of the fact that volunteers come and go. This is ...
JHR's user avatar
  • 141
4 votes
Accepted

Trouble setting camera position in Unity

There are several misconceptions here. First off, every Component and GameObject already has a pre-cached ...
DMGregory's user avatar
  • 133k
3 votes
Accepted

Is there a logical reason for SFML's Vector2 being templated?

Unity, for example, has both Vector2 and Vector2Int types (and so on for other dimensionalities), since C# didn't/doesn't have ...
DMGregory's user avatar
  • 133k
3 votes
Accepted

How can I fix this NullReferenceException error while all the references are set to specific objects?

First let's simplify your shooting triggers script. We'll use arrays to make the code shorter and faster. Instead of looking for ten different hard-coded names (and paying string comparison costs for ...
DMGregory's user avatar
  • 133k
3 votes
Accepted

How can I fully or partially colorize a SpriteRenderer and make its "color" value match the end result at 100% opacity?

After much trial and error, I was able to achieve what I wanted by modifing Unity's default "GUI/Text Shader" shader, which I downloaded from here under "Downloads (Win)" > &...
Pikamander2's user avatar
3 votes

Rotating 2D sprite around tilted Y axis

I think this would be easiest using SKTransformNode.setQuaternion instead. This makes it easy to express a rotation by some angle around any axis you choose, rather than only rotations around the ...
DMGregory's user avatar
  • 133k
3 votes

Fast way to calculate angular intervals and occlusion of circular objects in a 2D vision cone

Here are some optimization suggestions: 1. Filter unnecessary tests Objects located outside the field of view circle(distance>r1+r2) do not need to be detected. ...
Mangata's user avatar
  • 2,491
3 votes

Bouncing balls miss collisions, bounce the wrong direction, of lose momentum on one axis when hitting a corner

It appears that your code is fighting with the physics engine about who gets to control the velocity vectors of the balls. When there is a collision between two rigidbodies, then the Unity physics ...
Philipp's user avatar
  • 119k
3 votes

Area2D only detecting body_exited once

The ball being an static body is odd... I suspect the Area2D is not detecting the static body at all, see the issue: Area2D does not detect moving StaticBody2D. I ...
Theraot's user avatar
  • 26.2k
2 votes

Unity Application.Quit() doesn't work

There were some comments here but no actual solution. The answers of course exist by searching but not in this post. The ability to exit the game in BOTH standalone and editor mode is important for ...
Flashheart's user avatar
2 votes

Emulating 3d trajectory in top-down 2d game?

I created this version which uses a target position and t (time 0-1). I would loop this function in an update function if (t < 1) t would increase by ...
Joel Leonard-Best's user avatar
2 votes
Accepted

How to flip the scale of just a parent GameObject and not its children

Because of the nature of my 2D platformer, I was able to just use the flipX boolean on the Sprite Renderer. I didn't notice it was there! This code works great: ...
nataliadalomba's user avatar
2 votes

How to make raycast go through platform effector?

This example assumes you are using Unity, other game engines might work differently although the concept still applies. You could to use RaycastAll and check the position of the platform. This ...
Barreto's user avatar
  • 123
2 votes
Accepted

OverlapCircle detects collider farther away than the provided radius

The method Physics2D.OverlapCircle(new Vector2(transform.position.x, transform.position.y), 1); will return true if there is a collider that overlaps a circle of ...
Philipp's user avatar
  • 119k
2 votes
Accepted

Making a 2D Grid Map UI in Unity

You could use a setup with two cameras. The first one pointing at the 1st person view of the player. The second one pointing at a Tilemap and rendering to a render texture by setting that render ...
Philipp's user avatar
  • 119k
2 votes

KinematicBody2D stutters/moves back and forth

Are you not overshooting your target? You have this code: ...
Theraot's user avatar
  • 26.2k
2 votes

Is there a logical reason for SFML's Vector2 being templated?

Why would you ever want to use any other type than float for positional math? The other answer covers this pretty well but some aspects of your post has not been tackled. Is there a logical reason ...
Vaillancourt's user avatar
  • 16.3k
2 votes
Accepted

Fanning cards in 2D leads to cards continuing to move forever

How do cards stop You are using two curves to achieve that: spread_curve and height_curve. Now, the ...
Theraot's user avatar
  • 26.2k
2 votes

In Unity, how can I make sprites be affected by lights in the scene? The Sprite-Lit-Default Material doesn't seem to be working

Possibly, your sprites won't turn black because of ambient light. If it's at 1.0 then sprites won't look any different than when rendered with the base shader. Just ...
liggiorgio's user avatar
  • 4,626
2 votes

Why is interpolation passed into the rendering routine when the position and speed are related to the update routine?

Combining a physics engine that uses a fixed time-step with a variable-timed rendering loop can lead to very choppy movement. Sometimes you have two physics frames between two renders, sometimes none ...
Philipp's user avatar
  • 119k
2 votes
Accepted

Rotating 2D sprite around tilted Y axis

Try creating the art so that the red line is horizontal, then rotate it in Swift on its zRotation, and animate scaling along the ...
John Nyquist's user avatar
2 votes

How to make the player feel like giving up?

This is a common feature of boss levels, but doesn’t necessarily have to be exclusive to them. Make the level ridiculously impossible with quick death for the player all but assured, with the ability ...
bob's user avatar
  • 296

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