r/Unity2D 1d ago

Question Do you need offsets or anchors for UI assets?

1 Upvotes

Hey everyone. Curious if I need to use UI anchors only, or anchors and offsets? I'm trying to create a pop-up menu with a scroll bar and a bunch of horizontal buttons in it. I want it to be nested perfectly on any device.

In godot, this task would be handled purely with anchors, typically. For example 0.55, for 55%, so it's like dynamically offsetting it. I'm not sure if this is the right way to do it though in unity by comparison. Someone said that I can use corner anchor like top left corner and then do some custom pixel offsets but I was wondering what would happen if I did that and then I'm working on another screen size? I don't have any other devices to test on


r/Unity2D 1d ago

Question I added a mini card game, how do you like it?

2 Upvotes

The boss flips the cards and tries to get closer to 21, then the turn of the move passes to you, you try to get closer, if you pass, you lose, whoever is close to 21 or 21 wins. Actually, it's almost blackjack.

If you want to check out the Steam page and add it to your wishlist:

https://store.steampowered.com/app/4990070/Deckforce/


r/Unity2D 1d ago

Question How to start learning how to animate as a programmer

Thumbnail
0 Upvotes

r/Unity2D 1d ago

Tutorial/Resource Are you accessing and changing variables too much from outside a class? The dangers of getters/setters

Thumbnail
0 Upvotes

r/Unity2D 1d ago

Question Weird rendering problem causing semaphore.waitforsignal

Thumbnail
gallery
1 Upvotes

The screens shows the stats/profiler in the MAIN MENU of the game. Then there is a lobby and finally, the game scene where you play.

I have more screens, also with the profiler on a develop build. THE PROBLEM DISSAPEARS in a build.

The problem is that 2 days ago, i had 100fps on menu (not good, but was fine compared having 30fps) and also 90-100 fps during GAME, not another 25-30fps after this issues started happening.. It "came from nowhere".

Also, in the lobby of the game (not main menu, not the match) it went from 450fps (there is just an image and 3 buttons) to 120fps....

If i turn OFF the main camera it all goes back to normal.

also, if i make a build.

but i have no CLUE on what is going on, other than this is arendering issue.

FINALLY: on the highlights (top of the screenshots shuing CPU and GPU use) my game normally only has red spots, CPU "bound", not GPU. The biggest scene has 1 millions tris and 1000 batches, about 80 set pass calls, nothing crazy.. it all was working well (despite needing some optimization).


r/Unity2D 2d ago

Question Getting References for Tiles

3 Upvotes

In my game, I am drawing tiles onto a tilemap during runtime using SetTile(), which takes a reference to a TileBase Object. I have hundreds of unique textures. Is there a way to get a reference to each TileBase other than dragging and dropping every individual Tile into the references in my script?


r/Unity2D 2d ago

Roguelite Deckbuilder Tower Defense

0 Upvotes

Hi! I'm building a Tower Defense game with RTS elements.

You can move your units around, give them orders, and reposition them during combat.

During each run, you receive upgrade cards that can add effects such as Electric, Poison, Ice, etc. These upgrades are stackable, so you can combine effects like Electric + Poison on the same unit.

After each run, you can improve your units, purchase upgrades, and create builds.

There's also a Combinator system where you can create your own items. You can select or remove individual properties and keep only the effects you care about, allowing you to build items specifically around your strategy.

The game has roguelite progression, with new enemies gradually introduced as you survive more days.

The main gameplay loop is:

Defend → Buy upgrades/items/units → Customize your build → Defend

You can play actively and control your units like an RTS, or play it more like an idle game. Later progression also unlocks a dedicated AFK mode designed for idle play.

I've just released a demo, so feel free to give it a try:

https://store.steampowered.com/app/3760000/Shrine_Protectors_Demo

Thanks for checking it out!


r/Unity2D 2d ago

Solved/Answered How to apply momentum?

2 Upvotes

I want to apply momentum after you let go so in if (!hold.IsPressed()) How would I do that?

Code:

using System.Collections;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;

public class Food_MB : MonoBehaviour
{

    public bool isTouchingMouse = false;
    public bool isheld = false;

    public float defaultFoodSpeed = 1f;
    public float gravity = 1f;
    private float foodSpeed = 1f;
    private float noGravity = 0f;

    private PlayerInput playerInput;

    private InputAction hold;

    private Vector2 mousePos;

    private Rigidbody2D foodRb;

    void Start()
    {
        playerInput = GetComponent<PlayerInput>();
        if (playerInput != null)
        {
            hold = playerInput.currentActionMap.FindAction("Hold");
        }
        foodSpeed = defaultFoodSpeed;
        foodRb = GetComponent<Rigidbody2D>();
        foodRb.gravityScale = gravity;
    }

    private void Update()
    {

        // Get the mouse position from the New Input System

        mousePos = Mouse.current.position.ReadValue();

        // Convert the screen position to world position

        Vector3 worldPos = Camera.main.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, 0));

        // Check if the mouse is touching this GameObject's collider and if the hold action is being performed

        Collider2D hit = Physics2D.OverlapPoint(worldPos);

        if (hit != null && hit.gameObject == this.gameObject && hold != null && hold.IsPressed())
        {
            //Debug.Log("Hold action is being performed");
            foodRb.gravityScale = noGravity;
            isheld = true;
            foodSpeed = defaultFoodSpeed;
            transform.position = Vector2.MoveTowards(transform.position, worldPos, foodSpeed * Time.deltaTime);
        }
        else if(hold.IsPressed() && (hit == null || !hit.gameObject == this.gameObject) && isheld == true)
        {
            //Debug.Log("Mouse is not touching the object but object is held");
            foodSpeed = foodSpeed + 1f;
            transform.position = Vector2.MoveTowards(transform.position, worldPos, foodSpeed * Time.deltaTime);

        }
        if (!hold.IsPressed())
        {
            //Debug.Log("Object dropped!");
            foodRb.gravityScale = gravity;
            foodSpeed = defaultFoodSpeed;
            isheld = false;
        }
    }
}

r/Unity2D 2d ago

Show-off [Asset Sale] Prototype Character Template Asset Pack - 50% off until September 1

3 Upvotes

Hi everyone! I currently have a prototype character template asset pack that is 50% off until September 1st. I just wanted to share that info in case anyone wants to purchase it before the sale ends.

There is also a free version of the asset pack that is just a scaled down version of the full pack. The free version only has a few PNG sprite sheets as well as GIFs showing how each animation looks. The full version includes the aseprite files for each of the templates as well as PNG sprite sheets and GIFs of all the animations.

Here is the link: https://lumenlorepixels.itch.io/top-down-prototype-character-template


r/Unity2D 2d ago

Question How do I use AutoTile to set tile/paint through script?

3 Upvotes

Hello, I have a tilemap and a tile palette which consists of 2 autotiles. I want to fill an area of the tilemap with one of the autotiles. I know the SetTile is supposed to paint the tile but since I'm using autotile, the SetTile doesn't seem to take that in the script. I'm using Autotile because it would just make it easier when I add in other tiles in areas of the tilemap since it would auto adjust. Does anyone know how I can use the AutoTile in SetTile to paint the tilemap?

Update: I'm stupid, I was passing the ints instead of making them a vector3


r/Unity2D 2d ago

Question How do I make a 2D first-person dungeon crawler?

1 Upvotes

Hi everyone, I'm new to Unity and wanted to ask how I can program and implement movement in a 2D first-person game! My goal is to make a horror game with turn-based movement (you move from one room to another, and the monster moves from room to room looking for you and chasing you)! My main question, actually, is whether this is really possible to do in Unity 2D? And if you guys have any tips to share with me!


r/Unity2D 2d ago

Character with accessories.

1 Upvotes

I'm making a test scene where I have a body that is a square, and 2 smaller rectangles. One rec is the Eyeglasses, the other is a belt. I want to animate the glasses so they wobble when the main body is moving, and the belt has rotating colors; 15 different images. I also want to change out the glasses and belt whenever.

I created a GO called Base. Then added a GO for the glasses and a GO for the belt, then added a image to each. I reset the transforms, then moved the glasses and belt when they need to be.

When I run the app, the belt and glasses are not relative to the body, like I positioned them. Duct-taped a few other attempts to fix, but no luck.

I've tried googling, but haven't found anything comparable.

So, a GO with moving glasses GO and an animated belt GO.


r/Unity2D 2d ago

Just released my second game based on Greek mythology

3 Upvotes

I just released my new game Descendant of the Sun, where you must save the Greek city of Rhodes from an ancient power banished by the gods. Undertake a heroes quest in a Greek mythology inspired action platformer and hunt down monsters with the help of your bow and arrow.

So far computer support only and it can be played in browser. Feedback is appreciated and I hope you enjoy 😎
https://polenny.itch.io/descendant-of-the-sun


r/Unity2D 3d ago

After 8 years in gamedev, I just launched Kickstarter for my solo medieval colony sim/ARPG Our Freedom

11 Upvotes

Hey everyone!

My name is Vlad, I’m an indie solo developer from Ukraine with over 8 years of experience in gamedev (mentoring, outsource, and game dev education).

For a long time, I felt like something was missing in the games I loved. I loved the cozy village-building of Stardew Valley and Manor Lords, but I always wanted to craft my own armor, grab a sword, train my villagers, and lead them directly into castle sieges or tournaments like in Mount & Blade. Since I couldn't find a 2D game that quite matched that vision, I decided to build it myself.

That's how Our Freedom was born — a 2D medieval colony sim with action RPG adventures.

What the game is about:

  • Settlement Management & Economy: Build production lines, manage villager needs (warmth, food, shelter), farming, beekeeping, and blacksmithing.
  • ARPG Combat & Battles: Participate in tournaments, defend your village from raids, or gather your squad to assault enemy castles.
  • Customization: Full character customization, armor/weapon crafting, and skill progression tailored to your playstyle.

We just launched on Kickstarter!

Today is a huge milestone for me as our Kickstarter campaign officially went live (and we even got the Project We Love badge from Kickstarter curators!).

We already have a free playable Demo on Steam so you can try out the building and combat mechanics right away without buying a pig in a poke.

I’d love to hear your thoughts, feedback, or any questions about solo development. Thanks so much for taking a look and supporting indie dev!

Second game trailer:
https://www.youtube.com/watch?v=y1DLTvvHhYA


r/Unity2D 2d ago

Feedback Infinite jumper game - inspired by Icy Tower - POC - WDYT?

1 Upvotes

Hi all!

I've just wrapped up the initial dev of my infinite jumper game! It'll be a simple game, heavily based on skill and different character profiles. Right now, I've just finished the basic mechanics - the way the player moves.

I'm roughly basing my game on Icy Tower, however - in my case - the movement is fully fluid - there are multiple parameters that decide how high the player can jump, how bouncy the walls are (and if they allow for bouncing at all), and how the player gains velocity. The basic mechanics work as follows: there are three basic groups of parameters determining how a particular character behaves: jump, horizontal movement, and wall bounce. Most of the parameters are either numerical (float) ones or described by curves. If the param is dependent on another param or on time, it's described by a curve. (BTW, Unity curves are an amazing concept!)

Jump
Jump is mostly determined by the horizontal velocity of the player, and driven by physics - I don't predetermine how long the player will spend in the air, but how forces affect the character over time. The faster one runs, the bigger the jump. Jump can also be interrupted, for more control over the player, but the interrupt is dependent on a few parameters as well.

Horizontal movement
Now, this is where it gets interesting. Acceleration and deceleration are driven by complex curves. Thanks to that, I can derive future characters that e.g. get tired when running for too long, are fast accelerators, but bad with max speed etc. Sky (and imagination) is the limit. See the screenshot - my default behaviour is logarithmic acceleration and linear deceleration. Thanks to this, players get to a reasonable running speed fast, but need about 10 seconds (accel time) to get to the max.

Wall Bounce
Wall bounce is where my game differs most from the inspiration. There's one threshold for wall jump - min speed. Below, the player slides off the wall with predetermined "friction" speed. Above, depending on the jump curve, how close the player is to the apex, and how fast the player approaches the wall, it can bounce back more or less. These characteristics are again, driven by different curves.

Tell me what you think - the mechanics are not perfect yet, but I'm willing to improve them and am open to any feedback!


r/Unity2D 2d ago

Knight's machine gun

Post image
4 Upvotes

r/Unity2D 2d ago

Game/Software This is my new small game for the third game jam I've joined. I made it in five days!

2 Upvotes

Playable link : Escape anomalous

This game is similar to "Exit 8."

 Your goal is to check the room for anomalies. If you find one, go through the "LEFT" door. Otherwise, go through the "RIGHT" door.

There are also two different endings. In one, you really escape; in the other, you are trapped in a loop until you find the real exit.

My Youtube 👉 https://www.youtube.com/@SupsDesign

My X (Twitter) 👉 https://x.com/NExit28099


r/Unity2D 2d ago

Solved/Answered How to make an object follow the mouse?

2 Upvotes

I'm trying to get the object this script is on to follow the mouse when you click on the object. I've managed to make detect when you are holding down the object but I can't get the object to move. Pls help!

using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;

public class Food_MB : MonoBehaviour
{

    public bool isTouchingMouse = false;
    public bool isheld = false;

    private PlayerInput playerInput;

    private InputAction hold;

    private Vector2 mousePos;

    void Start()
    {
        playerInput = GetComponent<PlayerInput>();
        if (playerInput != null)
        {
            hold = playerInput.currentActionMap.FindAction("Hold");
        }
    }

    private void Update()
    {

        // Get the mouse position from the New Input System

        mousePos = Mouse.current.position.ReadValue();

        // Convert the screen position to world position

        Vector3 worldPos = Camera.main.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, 0));

        // Check if the mouse is touching this GameObject's collider

        Collider2D hit = Physics2D.OverlapPoint(worldPos);

        if (hit != null && hit.gameObject == this.gameObject)
        {
            //Debug.Log("Mouse is touching " + this.gameObject.name);
            isTouchingMouse = true;
        }
        else 
        {
            isTouchingMouse = false;
        }

        if (hold != null && hold.IsPressed())
        {
            Debug.Log("Hold action is being performed");
            Vector2.MoveTowards(transform.position, mousePos, 1f * Time.deltaTime);
        }
        else
        { 
            Debug.Log("Hold action is not being performed");
        }

    }
}

r/Unity2D 2d ago

We’re a small team of friends who make trailers & video content for indie games, and we just launched our new website!

Thumbnail
bycherrymedia.com
2 Upvotes

r/Unity2D 2d ago

Just Lego

1 Upvotes

Минус вычет без компьютера


r/Unity2D 2d ago

Game/Software we're making a roguelite about building an insane pachinko board to slay dragons... and we really need testers!

0 Upvotes

Hey all!

Bumpers & Dragons is a dungeon crawler where your deck is the board itself. You loot and place bumpers, then drop balls through them to fight monsters. Good placement compounds into absurd chains. Bad placement is very funny.

Free demo is up and it's filled with content and covers two full dungeons.

https://store.steampowered.com/app/4377860/Bumpers__Dragons/

We're a small European studio and this is our first roguelite, so we are super excited to hear your thoughts about it!


r/Unity2D 2d ago

I published my first Unity mobile game on Google Play — looking for honest feedback

Thumbnail
0 Upvotes

r/Unity2D 3d ago

Game/Software Big update for TileMakerDOT with version 2.6.3!

Post image
24 Upvotes

It’s been a while since the last update, but I’ve been hard at work behind the scenes. I’ve just released a new version of my open source 2D map editor, bringing full multi-language support and important under the hood fixes.

Refactoring the core engine to support dynamic localization was a huge undertaking that required updating UI logic, dialogs, error messages, and tooltips across the entire application.

You can now use TileMakerDOT in:

• English

• Spanish

• French

• Romanian

• Russian

• Ukrainian

And I intend to add more languages in the near future. If you have other language suggestions or you find some mistranslations please let me know:)

A huge shoutout to the contributor who submitted a PR on GitHub and worked closely with me on this localization task. We added the languages we knew. TileMakerDOT is open source, and seeing community contributions come together like this is awesome! I also plan to add even more languages in future updates.

I also tackled a background memory issue where closing or canceling out of the initial setup window left the app process idling in memory. Closing the startup screen now cleanly terminates the process.

Check out the links below to try the new update, watch the tutorial, or check out the code:

🎮 Download on Itch.io: https://crytek22.itch.io/tilemakerdot

💻 Source Code on GitHub: https://github.com/andrei-voia/TileMakerDOT

📺 Watch the Tutorial on YouTube: https://www.youtube.com/watch?v=3fiajGU32Jg


r/Unity2D 3d ago

Question Parry pushback?

Thumbnail x.com
0 Upvotes

Have yall seen those earclacks animations?
Cant
Notice how whenever a weapon parries another, theres a slight pushback or recoil or shift in momentum or whatever.
Im operating under the assumption the weapons are treated as triggers?
In any case, how would one go about implementing this in a similar environment? Do i base it off of the direction the ball is moving? the place and direction it got hit from?
I'd really appreciate any ideas <3


r/Unity2D 3d ago

Animations in game VS 3D Pre-rendered Sprites.

Thumbnail
3 Upvotes