The 2024 Developer Survey results are live! See the results

# Questions tagged [2d]

2D refers to two dimensional space where coordinates are represented with X and Y values.

3,537 questions
Filter by
Sorted by
Tagged with
65 views

### Limiting number of Game Object

So I have this script that summons a stationary laser that the player is supposed to not get hit by, but since there's multiple game object with the code and they can all trigger at making it ...
• 17
101 views

### Randomized bullet shooting bullet hell

So I'm making a bullet hell game and I have script for a basic bullet to spawn and shoot towards the player, but it's always at set intervals and I want it to be random, but I dont know how. I tried ...
• 17
1 vote
44 views

### Object moves continuously and won't stop until it hits an obstacle

So im fairly new to coding and don't know much and so I decide to improve this line of code I had before, by finding something online and now my object is constantly moving and won't stop unless it ...
• 17
26 views

### 2d top down movement physics: speed, max speed, acceleration, friction, velocity, delta

I am creating a 2d top down game and am trying to implement movement. My current approach is very simple and looks like this ...
• 1
195 views

### Tethering Two GameObjects Together By a Rope Through Code

What I need assistance with: I need to create a rope connecting two GameObjects together at runtime through code. One end will be connected to Transform _pointA ...
• 192
397 views

### 2D Pathfinding with rope constraint

I have a character linked by a rope to a fixed point, in an environment with obstacles. I want to do a pathfind that take into account the rope. Here, if the character followed my current pathfind in ...
• 51
32 views

### Even after changing Default Behaviour Mode to 3D, my scene still remains in 2D. Why?

I had created a new scene, which didn't have sky and directional light. To solve this, I created a new skybox, then added to the maincamera. But there was no difference to scene & game view. ...
73 views

### My Godot 4 2D game is running badly on HTML5 on some PCs

using Godot 4.2.1, My game is a pretty simple top down shooter, I tried exporting to HTML5 on itch.io and the game runs fine on certain PCs but not others ?... when running the game on my computer ...
• 349
50 views

### 2D drag and drop dynamic rigid body spinning out of control in Unity

I'm trying to make a 2d game that involves dragging and dropping certain dynamic physics objects (like squares) and I am a beginner. I need it to look like the rest of the object holds a weight when ...
34 views

### How can I instantiate an object on all tiles of a hexagonal tilemap?

On startup, I want to instantiate a text object on each tile (displaying its info). How can I accomplish this for a hexagonal tilemap? Here's my poorly written code that doesn't work. It seems to ...
29 views

### Inconsistent results from ApplyCentralImpulse with RigidBody2D

I'm working on a 2D top-down game using RigidBody2D for the player and enemies. They're bouncing and moving (using ApplyCentralForce) and detecting collisions just fine, however now I want to add a ...
64 views

### How to make enemies navigate around each other in a grid-based game?

I am making a 2D top-down grid-based game where the movement is similar to older Pokémon games so it's locked to a grid. I implemented A* pathfinding for my enemies with a bool[,] that indicates ...
• 21
38 views

### 2D orbit an orbiting body without ellipse

I have a monster (boss) that spawns a minion (m1) which orbits the boss. m1 can spawn its own minion (m2) which orbits m1. This creates a situation where m2 is orbiting m1 and m1 is orbiting the boss. ...
1 vote
144 views

### making a 5 minute Metroidvania prototype and wanna know if my dev process is good

I've been learning Godot and game dev as a whole since the start of this year and I've sunk dozens of hours into practicing making games in it, lately I've set out to make a very small sort of "...
• 349
199 views

### adding a knockback effect to a CharacterBody2D in Godot 4.2.1?

i was following a tutorial series on YouTube on creating a Zelda clone in Godot 4.2.1 and everything works fine, but the tutorial never implements a knock-back effect when attacking an enemy so i ...
• 349
17 views

### How to update a component field for a single player for all player views?

I'm making a 2 player game in which, when 2 players are in a room, they "toss a coin" to decide which of the two player "skins" they get. Now, the way I built the player "...
• 113
1 vote
103 views

### How do I compose RPG character with different equipment?

I wonder which technique is used to render 2D RPG character with different armor pieces and weapons. E.g. character can equip different chest armors, gloves, boots and helmets. They also can equip ...
• 225
29 views

### 2D Physics inconsistent across platforms

I want to create a black hole like gravity pull effect in Unity2D, and used that code for this: ...
• 97
42 views

### Line Of Sight in javascript DOM game

I am creating a 2D game in javascript using pure DOM, on my computer and on my cell phone WebGL or OpenGL do not work. How can I create Lights and shadows effects using Line Of Sight, for example, I ...
53 views

### Moment of inertia of an arbitrary grid of squares with different masses

I'm making a game where the player can create a 2D spaceship, one square "tile" at a time. In order to simulate the kinematics of the ship I need : To compute the CoM vector. That's easy ...
32 views

### Matrix parent-child transformation for 2D positioning

I am working with matrix math for parent / child transformations. I have to modify existing calculations to keep child scale constant while also keeping child position relative to its parent. Here's ...
47 views

### How to make a ball always bounce like in the game One More Bounce using Box2D?

I'm coding a game with Flutter and the flame_forge2d package (which uses Box2D internally). I want to make a game whose principle is similar to that of the game One More Bounce (a game where you have ...
90 views

### How to make a 2D Procedural Track Generation Algorithm

I would like to create an algorithm that generates a random track that a car can race on. How would I best go about such an algorithm? I will be using Unity 2D, but for my project I require using an ...
18 views

### Can I extract/bake the collisions generated by a tilemap collider?

Given a tilemap, with a tilemap collider, is it possible to extract/bake the current collision(s) onto a separate gameobject independent from the tilemap/tilemap collider? My 2D game streams a large ...
• 1,753
59 views

### How can I make a camera follow an instantiated object at runtime?

I have an object meant to represent a player that I'd like to spawn in at runtime. Because it is instantiated at runtime, I'm not sure about how to get the main camera in my scene to follow the ...
• 47
55 views

### How to make this soft sphere with Unity?

What methods should be used to create such a sphere in UNITY? This collider seems to deform in real-time, squeezing and monitoring collision information when the sphere collides. I cannot achieve this ...
• 1
26 views

### Springy / Stretchy rope

I have a 2D rope cutting game similar to cut the rope, and I want to add ropes that can be extended further than if it laid flat. Easy said: I want to stretch the rope. Currently I have a parent game ...
• 97
1 vote
88 views

### What exerts a force on my rigidbody?

I'm trying to create a simple 2D scene with two rigidbodies, which are connected by two pin joints. There is one large rigidbody, a green circle, which is slowly rotating at a constant speed (as its <...
• 111
35 views

### Collision manifold between shapes

I am implementing the narrow phase collision detection of a 2d physics engine. The narrow phase takes a list of shape pairs: [(s1, s2), (s2, s5), ...] And for each ...
1 vote
74 views

### Representing a concave polygon as a hull "minus" convex cavities

I am implementing 2D collision detection, and trying to tackle the problem of concave polygon vs. shape. The SAT works only for convex shapes. I was wondering if the following approach is a viable ...
34 views

### How do I move both the child & parent game objects at the same time?

My current code is: ...
63 views

### Circle to Polygon & Circle to Circle Velocity Resolution

I am working a 2d physics engine. Polygon to polygon collision and velocity resolution works without issue, but I am struggling to get working circle to circle and circle to polygon velocity working ...
1 vote
58 views

### Different Spacing of all Children Grid Layout Group

I am creating a top down 2D game, and I am creating randomized triangles on the ground. Such as this: This is to enhance the "knowledge" that you are moving. But it certainly doesn't look ...
1 vote
70 views

### Tiled Map in Unity is Darker than in Tiled Editor

I have a problem rendering a Tiled Map in Unity (.tmx format): the Tiled Map is darker in Unity than in Tiled Editor. I tried to change properties but got same ...
• 23
1 vote
79 views

### Get Impulse force needed for parabolic projectile launch

I want to create a projectile that fires upwards and in a sense falls down onto the player, like this: I found through some research I needed to use a "parabolic" equation. However it wasnt ...
• 404
700 views

### Creating a new camera in 2D mode sets it as default, despite not being the main camera

I created a new camera in Unity's 2D mode, and for some reason it's being set as the main camera, despite not being tagged as such. The original main camera is in fact tagged as "main camera"...
142 views

### Performance issues with high-resolution maps in 2D strategy games

I'm currently developing a 2D strategy game, and I've encountered some issues with the game map. My idea is to use a single 2D image as the strategic map for the game. similar to this (Supremacy 1914) ...
• 21
1 vote
81 views

### Issue with AttackArea Monitoring Before Attack in Godot 2D Game

I'm developing a 2D game where the player character can attack enemies using a designated attack area (Area2D node named AttackArea). I've encountered a problem where the AttackArea is active and ...
• 349
112 views

### Max velocity for smooth deceleration to destination

I am able to update velocity of my agent every 0.5 seconds. My agents max speed is 5f/s and max acceleration/deceleration is 2f/s. I know how far away I am from the destination. How to determine ...
• 13
1 vote
37 views

### Stop Jitter On Rigidbody2D From Rotation

I'm currently working on a geometry dash like game, except it is a triangle instead of a square (rubrub calls it a cube). I want it so that it rotates back to 0, 0, 0, when it is touching the ground. ...
33 views

### Help with 2D Pixel art sizing in unity

I just got into making a pixel art platformer for fun and I wanted it to work so that I could have a scrolling parallax background and also a tile set for the actual level to be played on. I ...
1 vote
21 views

### Is it possible to always make a trail crossing another trail on top in unity?

I have a couple objects with trail renderers. I was wondering if it was possible to make it so that when an object passes over the trail of another object, it always appears on top ? Because right now ...
• 21
1 vote
749 views

### Y-Sorting in 2D Isometric Games in Godot 4.x

I am having a problem with Y-sorting in an isometric Godot game. More specifically, when my character moves behind/in front of larger objects than one standard tile size, the rendering is inconsistent....
1 vote
155 views

### Curved Grid Layout Group

I can't find a quick answer anywhere, besides adding a 100 line script that I'm pretty sure is outdated. As the title suggests, I am trying to curve a grid layout group. I also want the children of ...
39 views

### Trouble setting camera position in Unity

I'm attempting to set the camera position in Unity through code. I have a simple 2D game and there's not much programming so far. I've attached a script to the camera, and in that script I've added ...
32 views

### Physics Material 2D Not Working When Object Rotating Around Player

I am trying to make a clone of florr.io (I'm not getting sued I know what I'm doing), assuming you don't know what that is, it is a game with petals rotating around you. I'm using a parent object ...
56 views

### How to align to 2D ground surface directly underneath?

I'm out of ideas at this point. I'm trying to set up a function inside my player controller that aligns the player with whatever is under it (usually the ground), ive tried using Raycasts, collisions ...
• 404
1 vote
98 views

### How to enable undo functionality in a custom Unity inspector?

I'm working on a custom inspector/editor for my player controller, the issue is every time I change something and click undo, the undo just undoes clicking on the object not modifying the value. After ...
• 404