Questions tagged [2d]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
107 views

How to perform a sliding collision between a square and a circle?

Please point me to the duplicate if this has been asked before. I couldn't find it. Basically, I am creating a 2d top-down game where the player is represented by a circle, and the tiles are ...
0
votes
1answer
15 views

Select box-shape grid between two positions on tilemap

I want to be able to click and hold on a certain point and mark it as startPosition. Then, while the mouse is held down and moved, mark that second position as <...
0
votes
1answer
63 views

Experiencing strange behavior in Unity when rotating a 2D GameObject according to the slope it is standing on

I am trying to rotate a square GameObject, so it appears to be standing perpendicular to the slope underneath it. However, when above a slope, the square constantly "spins"; it seems like ...
2
votes
3answers
292 views

Place Buildings to represent village

I try to convert an array of Buildings into a representation of a small village. There are several different buildings in a village, like factories that are located on the outside of the village, ...
3
votes
2answers
162 views

Why is my jump arc preview inaccurate?

I'm trying to draw an arc out of dots that previews a KinematicBody2D's trajectory after a jump but said preview always falls short of the body's actual jump and I cannot figure out why. Below is an ...
0
votes
1answer
115 views

Select specific tile in Tilemap

I am following this video tutorial on how to implement drag-to-select behavior like in an RTS. The only difference is, I'm using a tilemap. The selection area is a square which I can drag to make it ...
0
votes
1answer
39 views

Rotating player around planet causes drift in gun aiming at mouse

I have a bug with the rotation of a gun object that follows the mouse position. It has issues when the parent object player rotates. Example: The player has a gravity script to keep them aligned with ...
0
votes
1answer
79 views

Making a 2D gun spin from recoil when it shoots

I am trying to clone the game "Flip the Gun" as an exercise. Here is the behaviour I have so far. And here is the code I am using: ...
0
votes
1answer
30 views

Place tiles along a specific axis / direction

I want to be able to place tiles only in the direction I've started "drawing" them. For an example, if I click and hold on tile at position (0,0), and ...
0
votes
1answer
63 views

Normalize a rotation around the Z-axis (issue with GLM)

I'm trying to undo some transformations coming from an external tool*. I'm getting different results depending on subtle differences in the input and wondering how to convert to a rotation about the Z-...
0
votes
1answer
42 views

How do I get my fish to face the right way?

I'm making this 2d collecting game in Unity where you collect fish. However I can't get them to face the direction they are going. I've asked on some Discords and got no answer. Thanks in advance. ...
0
votes
1answer
512 views

Resizing canvas to match screen size in Unity WebGL

I'm learning how to make a browser game with Unity. I have set up the screen display dimensions to 960 x 640 (I read that it's a safe resolution to use. Feel free to correct me). I created a Canvas ...
0
votes
1answer
40 views

(Hitbox) OnTriggerEnter2D only work if enemy is moving

(UPTADE) I am developing a 2D Topdown Rpg Game. I have a problem with trigger colliders. I have button which make active an object and ı use it like Hitbox when i press button ı destroy enemy if it is ...
0
votes
1answer
62 views

How to stop Players and Enemies from pushing each other

I am developing 2D Top-Down RPG game. I have script that makes my enemy follow the player, and when they touch the player, the player will start to lose HP. Everything works well, but when they touch ...
1
vote
1answer
18 views

Maintaining facing direction at the end of a movement

I want to make my 2D top-down walking animation stop and revert to the idle animation while continuing to face in the same direction as the previous movement. For example, when I go up then stop, my ...
0
votes
0answers
16 views

2d packing shapes in rooms

I'm not sure of the correct terms for this so having a hard time searching. But I have a series of 2d top-down rooms made up of random grid sizes between say 5 and 10 on the x and y axis. Each room ...
3
votes
1answer
105 views

My Earthbound-like Movement Script works in Unity Gameview, but runs differently in Gamebuild

First programming question I've ever made in my short journey. I'm trying to create a script which moves members of your party in a line behind you (think Chronotrigger or Earthbound). Here's a clip ...
0
votes
1answer
278 views

Press and hold camera movement with mouse in new Input System?

I am transitioning to the new movement system and am having trouble figuring out how to move the camera when a mouse button is pressed and held. Here's how I did it before: ...
0
votes
1answer
108 views

How to apply Time.timeScale only to certain scripts?

I have a need to pause my game and the simplest and most clean way that I know of (other than completely designing my own time system) is by using ...
0
votes
0answers
27 views

Controlled Wall Jump 2d Platformer

I would like to be able to control the intensity of the wall jump of the character, enabling the character to jump in short bursts upwards a wall and in long button presses across the wall. I have a ...
2
votes
1answer
125 views

Predicting trajectory of Box2D physics body using both: linear dumping and gravity

I would like to calculate position of physics body after some time because of predicting shots trajectory in my game. I found some great answer here where Iter Ator provides equation to calculate ...
1
vote
2answers
410 views

Performance of many canvas drawImage calls is very slow

I'm developing a top-down 2D tile-based canvas game. I have a single sprite sheet of all my tiles, and then a JSON tile map array of where they're placed. Previously I would render all the layers of ...
1
vote
0answers
46 views

Corgi Engine - Character glitches with "jump" animation on top of a ladder

I'm new to Corgi Engine and Unity in general. I have an issue that I could find a way to resolve. I'm using CorgiEngine's "RetroLadder" prefab and extended "Rectangle" character ...
0
votes
2answers
298 views

"Update cannot be an iterator block" when trying to wait for jump to finish

As of now, I'm getting a C# error (CS1624) stating that: The body of PlayerMovement.Update() cannot be an iterator block because void is not an iterator interface type. The error is within the ...
0
votes
2answers
56 views

Main Camera re-sizing in 2d

My UI : An UI from YouTube video : Look my camera's size is 10 and his camera's size is only 5. But, my camera's width is larger than height. If you look at scale (x,y,z)=(1,1,1). I tried to change ...
1
vote
1answer
271 views

Is it possible to somehow change the collider points to match sprites during the animation in Unity?

Is it possible to somehow change the collider points to match sprites during the animation in Unity? I am using the Unity built in animtion recording feature. I would like to change the points of some ...
0
votes
0answers
105 views

How to draw a rectangle at x,y where x & y are in pixel?

Here is my code : ...
1
vote
3answers
1k views

How to Make Border of 2D Game in Unity

I have a border by default. But, I'm having trouble detecting if my object collides with the border. I am looking for efficient ways to do this, and I am not sure what should I use. I thought using a <...
0
votes
1answer
411 views

Character falls through the Platform Effector 2D in Unity. How can I fix it?

Character falls through the Platform Effector 2D in Unity. How can I fix it? Here is the demonstration: https://imgur.com/G5YkTxa. I tried changing the Edit - Project Settings... - Physics 2D - ...
1
vote
1answer
187 views

How can I jump down from a platform in Unity?

How can I jump down from a platform in Unity? I use two 2D colliders: one is my character, another one is platform. These colliders allow my character to stand on platform. Now whenever a characters ...
0
votes
1answer
199 views

UNITY: How to LOAD save file from main menu

So I've created a simple main menu with a new game, load game, and quit game buttons. In the new scene where I've created pause menu save/load buttons work, I've created a new object and attached a ...
0
votes
1answer
41 views

How to Change an Icon based on what Collider the Player Hits

So I have a 2D platform game where a player goes around collecting fruit but currently I only have one icon. Currently I use an image on a canvas to display the fruit image. How can I make the UI ...
0
votes
1answer
272 views

Item counter unity

How is it possible that a create an item counter in unity? My current Scripts - Counter.cs ...
0
votes
0answers
19 views

How to see the surface arc in Unity?

How to see the surface arc in Unity? There is the tutorial and in this tutorial we can see the arc in editor: While I can not see it. I checked that all my gizmos are enabled. How can I enable the ...
1
vote
1answer
88 views

2D shadow from polar coordinates has hard cut-off at a certain radius

I'm trying to cast shadows from a 1D texture that goes from white to back according to the distance given by an occlusion map. That part I think I got it right. The problem lies on the algorithm to ...
0
votes
1answer
407 views

Looking for a game engine to make a game like "Ikariam" or "Ogame" [closed]

I'm an IT student and currently in my spare time I want to start a project. I would like to make a game that resembles a browser games like "Ikariam" or "OGame". I don't want this ...
0
votes
1answer
175 views

Removing walls of a tilemap at runtime in unity

I've been trying to implement some light procedural generation into my game, nothing fancy. Just spawning rooms down in different areas in order to add some replayability. I watched a few videos and ...
0
votes
0answers
21 views

How can a make a game end and display win message when the mouse/figure is placed/clicked on a certain tile?

I am trying to make a game, kind of like Minesweeper, but instead of looking for mines, you are looking for a 'hidden base' that is hidden under one of the unturned tiles. I am new to this and have no ...
-1
votes
2answers
72 views

How do I fade between scenes when my player reaches a certain point

I have made a 2d Platformer but when my player reaches the end of a level I want it to fade to the next level. How can I have multiple scenes that each have one level and that fade in and out? Load ...
0
votes
0answers
27 views

Make 2d sprite move in unity

At the moment I have a movement script which moves my player in Bothe directions but it only faces 1 way - ...
0
votes
0answers
282 views

How can I make Enemy follow the player in unity

I have a 2d platform game where I want the enemy to follow the player for some time Currently the enemy constantly follows the player - ...
0
votes
2answers
513 views

In unity how can I make a checkpoint system

I have a 2D platformer and if my player dies, he goes back to the start, but I want there to be checkpoints. My current Respawn script: ...
2
votes
2answers
170 views

How to smoothly interpolate 2D camera with pan and zoom

I'm developing an animation application with a 2D virtual camera. The camera viewport can be positioned and scaled in the keyframes and is then interpolated to render the final animation from the ...
0
votes
1answer
166 views

How is it possible that I make my player die in unity

So what I have is a 2 platform game where I want my player to die when it hits a trap and go back to the last checkpoint it when past Currently I use this script: ...
3
votes
1answer
81 views

Getting a TileMap wrapping as a toroid on player movement

[libgdx version 1.9.13 - Desktop Game] This question seems to have been asked many times, but I have yet to find a decent solution. I want to display a map without edges, where the player moves in all ...
0
votes
2answers
150 views

How to Implement Trap Damage Unity

Currently, I have a 2D platformer game, and I want to implement a function that can make the player die and go back to the start or a checkpoint when he interacts with a weapon or trap. What I have in ...
1
vote
1answer
341 views

How to make 2D lighting in JavaScript

I am making a recreation of the 2D voxel game Terraria in JavaScript. Like most sandbox games, Terraria has lighting, but because I am using JavaScript, performance is going to be an issue. I have ...
0
votes
0answers
37 views

Unity 2D switch direction in an auto runner

I'm new to Unity and I'm trying to make a 2d endless runner (something like Super Meat Boy Forever), and one idea was that when the player touches a wall he would change direction. I tried to ...
0
votes
1answer
700 views

Effective solution for showing the outline of the player sprite when behind objects or tiles that are meant to be in foreground

I'm very new to Unity and I'm now experimenting with possible ways to show the player outline when he/she is behind objects or tiles. This is what I came up with: My setup Built-in rendering pipeline ...
2
votes
1answer
389 views

Unity Tilemaps Best practices

I'm pretty new to Unity and I just finished some courses and tutorial found in the official documentation. I'm now in the process to apply what I learned so far using different assets from the ones ...

1 2 3
4
5
66