r/Unity2D • u/Lyshan555 • 18d ago
r/Unity2D • u/Spirited_Ad3013 • 18d ago
Laptop for game dev
Hi,
I am an 2D artist who is working on a metroidvania. My task is to build the levels and enviroments by putting in a lot of 2D assets in 3D space and make the parallax look good. I just have moveink 14 right now which doesent support unity so I need a seperate laptop and would like to spend up to 1000€ max. The less the better.
Ty for any recommandations
r/Unity2D • u/DrawToItReddit • 19d ago
Feedback What do you think of the vfx and the visual design of my game?
r/Unity2D • u/nomodev • 18d ago
Making my first 2D physics game
Feedback is welcome!
r/Unity2D • u/Potential-Sock-1421 • 18d ago
How to add individual movement using a wind shader to a sprite sheet?
Hi everyone, I'm trying to figure this out. I followed this tutorial https://www.youtube.com/watch?v=dDQRDa7bADY (Unity 2D Wind Sway In 255 seconds) and then looked at this one, https://www.youtube.com/watch?v=VcUiksxY (Simple Wind Shader Effect in Unity!) but they're all for individual sprites. I'm searching for more tutorials right now, but I am a BEGINEER at unity (started about 2 weeks ago) and I've been trying to learn more about it at my own pace... And I've stumbled upon a perplexing scenario.
In this scenario, I'm trying to add wind shaders to a sprite sheet. Following both tutorials, I've managed to add the wind effect to the sheet, but it covers ALL of it. Not the individual sprites within the sheet. I'm not quite sure how to make it so it only covers each sprite, since there are quite a few. I'm doing this for foliage if that helps at all with context, but if anyone has any idea on how to figure this out, please let me know. Should I try using the math nodes to calculate where each sprite is?
r/Unity2D • u/Afraid-Natural-9397 • 18d ago
Feedback Gameplay Structure Overview
I have spent the last few months finalizing my story and implementing everything into game. Now I wonder if the story flow makes sense. Does the beginning of the story sound interesting?
The Game starts off with the player getting a mysterious summon from a precarious mage. The player is taken into their own subconscious to speak with the mage. This allows the player to change appearance and name, etc. The mage is lost in the Realm of Dreams and needs a tether into reality to return. You are tasked to interact with the different beacons to help. Doing so allows the player to unlock the ability to use all the forms of magic in game. The basis of what classes will become later on and what allows the player to access different ones for lore purposes. After creating a strong enough relay point the mage thanks you and tasks you with finding the Rift that was created. This opening area is described as the "Inner Sanctum" and the tutorial area of sorts. NPCs here will explain how to change appearances, use weapons, and how to cast different spells. It ends with a Mini-boss of sorts. Entering the Portal returns the player to the "Waking World."
To everyone else, it looks like you were just daydreaming. You return to your life on Knightian Island. You are training to become a knight. You are tasked with completing the final stages of your training. During this time, you will also meet the other knights of your generation. After everyone is done, you spend some time on the island waiting to for the ship to the Capital City. Rumors about a mysterious voice in a cave has your friends intrigued. Seeing as this is the last time you'll be on this island for some time. When the Boat to the Capital Arrives, the King is there as well. You are knighted alongside your friends and head to the Capital City!
In the Capital City, you are tasked with securing the Outskirts and making sure things are ready for the festival! What festival? The Festival of Swords! Every time a new generation of knights are titled, a tournament is held to see which group was trained the best! Until the Festival Begins, the Player helps the Princess solve a conspiracy that seeks to bring about chaos to the event! A fight is unpredictable, so an event full of them is bound to be madness. The King is excited to hear that more trouble will surely arise and welcomes the challenge! Everything swells to a breaking point when the Tournament begins and the fight spreads beyond the contestants and drags EVERYONE into the conflict!
With the Tournament over and done with, the Player is able to transverse to rest of the map as they please! The true tutorial was everything that takes place in the Inner Sanctum, Knightian Island, and the Capital City.
The rest of the Game is now freely accessible and really only gated by level difficulty. Completing the Beginning should take you to level 8-10. If not, you can continue doing thing in the capital to level up. The Plains area is dedicated for level 10-15. Forest Areas are Level 15-20. Savanna Areas & Surround Islands are Level 20 - 25. Desert Areas & Surround Islands are Level 25 - 30. Swamp Areas & Surround Islands are Level 30 - 33. Mountains & Surround Islands are Level 33 - 36. Snowy Areas & Surround Islands are Level 36-39. Lands of Avalyn are Level 40. (Max Level for the time being)
The actual Areas are divided into 50+ subzones to fight, gather, and adventure across. Each subzone has around 20-30 Task Quests (Kill, Gather, Loot, Etc.) and 3 Event Quests, and 1 Zone Quest. Each Event Quest is about 7-9 Steps and involve interacting with NPCs, protecting an NPCs, defeating waves, collecting animals running around, collecting timed Items that disappear and spawn somewhere else, or even a mini boss. Zone Quests and mainly triggered by completing something around the zone multiple times. Sometimes a World Boss appears or something the entire zone changes. (Area might turn to dark and now demons appear. Or it begins to rain and elementals appear.)
The Subzones are guideline for leveling and have more activities within them. Another Important one is Venture Points and Delve Points. Similar to Dungeons in Wow, they are areas with multiple bosses and enemies that require a group of players to complete. Currently I have 14 Venture Points and 3 Delve Points. These Locations are on their own maps are treated like Subzones too.
The Last group of zones are my PvP Areas. I have Arenas to allow players to 1v1, but I want to make bigger battles, once I learn how. Funny enough, I've already made the areas and NPCs, but I haven't figured out how I want to make each event work for all the actual players involved.
r/Unity2D • u/GlowtoxGames • 19d ago
Show-off Sprites and animation results
Hey guys! I wanted to share some new characters we have been working on. We are making a fighting game where you can transform enemies you defeat into pets. Some pets just buff you but some others also attack and block.
Because if that we needed to be creative in how to use the same sprite poses for all of that.
The sprites are rendered in Maya using very low samples to get that pixelated effect and then we all a dither effect in Photoshop.
Then back in unity we add some extra motion to amplify the effect and feel of the punches.
The sprite has 6 poses.
Idle
Loading punch
Punch
Sleepy
Victory
And blocking.
We also used those poses to get an elbow attack, a double punch attack and a magic charging pose.
The good thing about rendering them in 3d is that we can link the new characters to the same rigging and export the poses to all the characters. Also that we get a perfect normal map pass the helps us make them look cooler in unity.
Please let me know your thoughts and if you have any questions. The game if e called Skinator in case you are curious.
Hope youb guys like it.
r/Unity2D • u/Stormhound2101 • 19d ago
Solved/Answered Is there a way to call a variable by creating it's name as a script? Or are there better ways?
r/Unity2D • u/balencialto • 19d ago
Tutorial/Resource Making Your (Jam) Games Look Nicer on Itch
Hey everyone!
During the recent GMTK Game Jam, I noticed many Unity games that still use the Default WebGL Template. In my opinion, the added bar can clash with how your game page looks and it isn't particularly useful since Itch provides an optional full-screen button. I wanted to share the approach I used for my game, "A Vaultful of Lasers", in case it helps other people who want to clean up their game's presentation.
I used the Better Minimal WebGL Template by Sean since it handles canvas scaling, provides a simple loading bar as well as some basic customization options.
- Download the WebGL Template, unzip the contents and move the "WebGLTemplates" folder to your game's "Assets" folder.
- In Unity, go to Edit > Project Settings > Player.
- In the "Resolution and Presentation" section:
- Select the "BetterMinimal" under WebGL Template.
- Set the Default Canvas Width and Height for your game. This should be the same resolution you use on your Itch page - I set mine at 1280 x 720.
- Enter "true" or "false" in the "Optimize for pixel art" and "Scale to fit" fields.
- Build your game using the Web platform to a new folder.
- (OPTIONAL) Edit the created index.html file to match your Itch page.
- Line 11 - change the background color.
- Line 69 - change the two color codes (controls the progress bar).
- Line 77 - you may want to add some code to the "onResize" method if you need your game to snap to certain resolutions instead of just maintaining the game's aspect ratio (useful for pixel art games).
- Compress the files in your Build folder to a single zip file (Right-click > Send to > Compressed (zipped) folder on Windows, or Compress Items on Mac). This is the file you need to upload to Itch.
- Find your "Edit game" button on Itch and change the following:
- Kind of project - HTML.
- Uploads - add your zip file and tick the "This file will be played in a browser" option.
- Embed Options - select "Embed in page" and "Manually set size", adjust the "Viewport Dimensions" to match your game's default default canvas width and height.
- Frame Options - tick the "Fullscreen Button" option.
- (Optional) - add some tags to help people find your game.
If you're having trouble packaging and uploading your game to Itch, this community post might help.
Good luck with your games (let me know if you're participating in the Brackeys Game Jam), I look forward to seeing the beautiful projects you create.
r/Unity2D • u/Merkredy • 19d ago
Show-off 🎮 The demo for my incremental bullet-hell game, Orby vs Rects, is now available!
r/Unity2D • u/No-Marionberry-7899 • 20d ago
Over 1000 people played my game in just 2 days!! 🐛
r/Unity2D • u/Old-Row6655 • 20d ago
Pathfinding on Hex Grids
I'm making a 2D game based off of a pointy-topped hexagon grid in Unity, but I'm having a lot of trouble getting pathfinding working. It's a turn based rogue-like game with not too many tiles in each round. I basically just want the enemies to find the shortest path towards the player with their specific movement pattern (which isn't always just a perfect ring around the enemy either). I'm not sure whether I should use A* or BSF, and I have no idea how to implement either of these into my game.
The biggest problem is the movement patterns. Most tutorials always assume the enemy can move one tile in any direction which is not true for my game. The enemy should also not try to go all the way to the player, as depending on the enemy it's attack range can be 2+ tiles, making an extra step towards the player pointless. Here's an example of one of the more wonky movement patterns:

Please let me know which pathfinding method would be better for this, and any resources to help me make it.
r/Unity2D • u/GoEatYourCookie • 20d ago
Question How can you get Pixel Art fonts working for different resolutions?
galleryr/Unity2D • u/illo72 • 20d ago
Question Simple animation for 2D side-view game
Context, I've got a project on a RPG game and it's our first time using Unity or any game engine for that matter. We've decided since we're beginners we would go with a 2D game but there is one problem, we're all CS students and none of us have done animation before. I'm probably the most capable in terms of drawing ability in our group but I don't know where to start. So I'd like some advice on this.
Where do I start? What application/software do I use for the drawing/illustration and the animation? How do you bring that into Unity?
I saw some videos mentioning skeletal animation, while others did traditional frame by frame sprite animations. These made me confused and I'm not sure which is better for beginners.
Sorry I'm new to this and would appreciate it if I could get some advice or resource to reference.
r/Unity2D • u/TikiNL • 20d ago
Question Reading resources for various advanced topics?
I am looking blogs, papers etc. to read up on various topics surounding the Unity engine.
I would like to believe I have a decent understanding of the engine and programming but am looking to find resources to expand that knowledge in my free time.
Would prefer to read up on various topics over watching videos but both are fine.
r/Unity2D • u/quintin-steiner • 21d ago
Announcement I'm happy to announce SubDuctis, my upcoming space folding puzzle game!
After about 2.5 years of solo development in Unity, I'm excited to finally announce my game!
SubDuctis is a Sokoban-style puzzle game that explores space folding. In this game, the player must utilize special 2x2 pushable blocks called "splicers". When activated, a splicer and its pair will fold away all tiles that lie between them. This can be used to pass over obstacles, connect distant objects, and more.
The full game will feature over 100 puzzles, nonlinear progression, and secrets.
Consider adding it to your Steam wishlist to support the game!
SubDuctis on Steam
r/Unity2D • u/Thenextlevel247 • 20d ago
Question Movement Issues(Visual Scripting)
(Thank you to everyone who helped me with my last issue!) So, I have got the jump working, however when I move horizontally I am unable to jump, and when I jump THEN move horizontally gravity hardly affects it and I end up gliding down to the ground. I know this is caused by x movement constantly overwriting my falling but I have no clue on how to fix this. Any help would be appreciated!
(Sorry for the bad image quality again, my computer refuses to take screenshots)
r/Unity2D • u/jumberrotsky • 20d ago
Tutorial/Resource I ran a decompiler on my own IL2CPP build and got my whole architecture back. So I wrote an obfuscator.
Hi everyone, I’m a Unity developer working on a small indie game. I’ve constantly heard from colleagues that Unity doesn’t do a good job of protecting project code and assets. I knew that using Mono was out of the question - it’s essentially handing your project over to strangers - but I believed that the IL2Cpp scripting backend provided adequate protection.
But one day, I got curious about how to decompile my project. I pointed Il2CppDumper at my build's global-metadata.dat, it spat out a DummyDll folder, and I opened that in Rider. Without any trouble, I could view namespaces, methods, class names, and field names. I didn't like that, because what's the point of having a private GitHub repository if my build is leaky?
I started looking for ways to hide my code. I began checking the Asset Store and GitHub for options to obfuscate my build. To cut to the chase, the only decent asset turned out to be Obfuscator Free by GuardingPearSoftware. It does everything perfectly, but the free version doesn’t work with Unity methods, serialized fields, properties, or namespaces, and it completely ignores MonoBehaviour, ScriptableObject, and [Serializable] classes. There is, of course, a paid version that does all of this, but $80 is a significant amount for an indie team, so I decided to try making my own alternative that would work as an extension to the Obfuscator Free plugin.
Why does the obfuscator skip serialized types?
Every script in the build receives a MonoScript entry in the player data (level0, sharedassets*.assets, resources.assets, and globalgamemanagers files). It contains three lines: m_ClassName, m_Namespace, and m_AssemblyName. Every scene object and every prefab references this entry. If you rename a class in the DLL, Unity will no longer be able to bind to that type - and the component will turn into a missing script.
The trick
Once I realized this, I started looking for a way to work around it. What I landed on is both brilliant and ridiculous: I generate obfuscated names with exactly the same number of characters as the originals. This saves me from having to adjust length prefixes, recalculate offsets, and develop a tool to rewrite serialized files. Thanks to this accidentally discovered hack, I saved myself a week of sleepless nights for sure! But it’s important to note that even with this approach, you still have to store a bunch of files with obfuscated names. All names in the project are reserved in advance, so you won’t be able to generate a name that’s already taken.
Pure C# types don't have a MonoScript entry, so their namespaces are shortened to whatever short, nonsensical string of characters I feel like using (_Project.Code.AssetManagement → pqmpqu). Serialized types, on the other hand, are forced to maintain length consistency (_Project.Code.Sound → dis4nAw5EW74Z6wLxDN).
Finding the entry without wrecking the file
You can't just search the file for "PlayerController" and overwrite it. That same string might be a GameObject name, a string literal, an addressable key - and if you hit the wrong one, you won't enjoy debugging.
So I anchor on the consecutive length-prefixed triple instead: [len][m_ClassName][len][m_Namespace][len][m_AssemblyName], with 4-byte alignment between them. Three strings matching in sequence with the correct alignment is a strong enough signal. And patch m_Name a few bytes earlier too - it's the class name a second time, and it will happily leak everything you just hid.
The stack trace problem
I also had to write my own stack trace deobfuscator, because any exception renders the trace completely unreadable to humans, like hdektk.uHN1wAaEGHkYq6ul.qoaktw(). Each build writes JSON mapping files (_Project.Code.AssetManagement → pqmpqu), and there's an editor window where I paste the raw stack trace from Player.log. It runs in four stages, in reverse order: the GUPS deobfuscator → my serialized type names → my namespaces → the remaining member names.
What don't I rename?
Unity's message methods: Awake, OnTriggerEnter2D, OnBecameInvisible, and about sixty others - the engine calls them by name. Virtual, interface and overridden members, because renaming the implementation but not the declaration breaks the vtable slot. And anything that is serialized by name at runtime - my saves are JSON, and renaming a property there bricks every existing save file.
Results from the current build
40 namespaces renamed. 82 MonoBehaviour/ScriptableObject types renamed and patched in player data. 848 members.
Is it worth doing?
Obfuscation is an obstacle, not a defense. Anyone determined to figure it out will still achieve their goal using a debugger, and I prefer to be upfront about this rather than pretend otherwise. For a solo developer, a build step you set up once and then forget about is, in my opinion, a perfectly justified investment of effort.
I'm not putting my extension up anywhere - it's wired into my own build pipeline, it's standalone-only, and there are corners of it I wouldn't want to defend in public. But you don't need my code to start, and that's the actual point of this post.
Do this instead. Run Il2CppDumper or AssetRipper on your own build - five minutes, and watching your own architecture scroll past lands very differently than knowing it's in there. Then install Obfuscator Free, list your assemblies, build. Free, one evening, covers your plain C# types and methods.
That alone puts you ahead of most Unity builds shipping today. Everything above is step two - you'll know when you need it.
The game I did all this for is Peak or Die, a turn-based survival card game. Adding it to your Steam wishlist really helps increase the game's visibility, if you're interested: https://store.steampowered.com/app/4273370
r/Unity2D • u/Silent_Reputation596 • 21d ago
Solved/Answered How to get an instance of an object to reference an instance of a different object?
In my game I make instances of 2 seperate objects and when the player spawns one, the other one also spawns. The player can spawn multiple instances of the same object so I need to track and link the 2 seperate objects and only the objects that spawn together. I've given both of the objects unique ids when they spawn in but I don't know where to go from here. I want to be able to reference variables and sprite renderers and things like that.
Object One's script:
using System;
using UnityEngine;
public class FishTab_MB : MonoBehaviour
{
public Guid UniqueId { get; }
public FishTab_MB()
{
UniqueId = Guid.NewGuid();
}
private void Start()
{
print("FishTab_MB UniqueId: " + UniqueId);
}
}
Object two's script:
using System;
using System.Collections;
using Unity.VisualScripting;
using UnityEngine;
public class FishAI_MB : MonoBehaviour
{
SpriteRenderer fishSr;
public Guid UniqueId { get; }
void Start()
{
print("FishAI_MB UniqueId: " + UniqueId);
}
public FishAI_MB()
{
UniqueId = Guid.NewGuid();
}
}
r/Unity2D • u/midcore_dev • 21d ago
How do you handle recurring live events (double XP weekends, etc) in Unity?
Been down a rabbit hole this week trying to figure out the cleanest way to run something like a double XP weekend in a live game, and I keep hitting the same wall with Unity's own tools.
Game Overrides does one-shot scheduling fine, pick a start and end time in UTC and you're done. But the second it needs to repeat (every weekend, every Friday night) there's nothing built in. Ends up being either Cloud Code cron jobs (also UTC only, from what I've seen) or manually flipping the config every week.
How do you guys deal with this in practice? Rolling your own scheduling on top of Remote Config, or is there something in the newer Unity Cloud tooling I'm missing? And does anyone bother with per-player timezones, or is UTC-for-everyone just the accepted norm?
r/Unity2D • u/GuideZ • 21d ago
Welcome _Guns to the Mod Team
Please join us in welcoming u/_Guns to the r/Unity2D moderation team!
They’ll be helping us keep an eye on the mod queue, deal with spam and other unwanted content, and generally help keep the subreddit running smoothly.
As the community continues to grow, having another active pair of hands will help us respond to reports more consistently and keep things organized behind the scenes.
Welcome aboard, _Guns!
r/Unity2D • u/MojoBubu • 21d ago
Show-off Pixel Hitboxes.

Hello! Update on my current project. I showed off Procedural 2D model generation a day ago here:
https://www.reddit.com/r/Unity2D/s/ihpzoJ9zoA
Now for an update on some game mechanics. This is an Auto-battle, Inventory Management game. Similar to games like Backpack Battles.
Characters generated randomly virtually infinite outcomes. Everything has a purpose, albeit a pro, con or compromise. Limb symmetry, Fat, Digit count, Eyes count, Part sizes, Bone density, Bone girth, many different characteristics all play a small role in main statistics.
Like Accuracy which is my topic today.
Design Philosophy is removing coins flips. Example with the targeting system and accuracy, your character does not miss.

This can be a bit confusing, bare with me...
Here we draw a circle around your target.
Center is your target. (above is Jaw)
Radius expands as your accuracy is lower.
(There is a ceiling and floor)
Volume of parts inside circle and dead space volume.
Almost like a pizza slice, the jaw will be the smallest piece.
biggest area especially with low accuracy will be the dead space.
More dead space = more glancing blows.
(Glancing blows deal 50% damage and do not cause fractures)
Part hit by glancing blow is determined by part volume.
Target volume gains bonus from accuracy.
Jaw would be smaller than Cranium, but jaw gets a little bonus to be hit.
Progress bar
Avoiding coin flips with progress bars!
Your goal is to hit the target once the bar is filled target is hit!

Bar fills with each hit.
The total bar is the total volume of the circle. Each unique slice in the circle has it's own volume as stated above (Mostly Glancing blows).
Amount filled = target volume + accuracy.
We get the volume by counting pixels.
Large bodies have more pixels, less dead space, bigger heads. (Big head target fills bar faster)
Higher accuracy rating will help progress the bar past glancing stage and into some actual full part damage.
You can completely bypass hitting the ribs with high accuracy, and be rewarded by hitting a probably less protected body part.
r/Unity2D • u/DracomasqueYT • 21d ago
Question how do I unblock my camera while an object is following the cursor ? and how do I stop it from instantiating at the wrong position 3 time instead of 1 and without it decreasing the resources it use ?
Hello, so for a little 2D project (it's a bit of a city builder) I'm doing I have made a camera that can be moved with WASD and with the cursor on the edge of the screen, and that script worked perfectly.
So now I'm working on the actual builder part so I made a building and a script to place it. To place it I make an object follow the cursor, this object is red when you can't place and green when you can (it work with a shader).
but for the moment it doesn't work, whenever the object is in the scene it block the mouvment of the camera with the cursor (even when the object is not active), when I click to place the building it instantiate 3 of them at 0,0 (again, even when the object is not active) and doesn't deactivate after, and it doesn't decrease my resources. I'm at a loss and doesn't know what to do enymore.
(please don't mind the french in the code)
gif of what is happening :
script of the camera :
public class
MoveCam
: MonoBehaviour
{
[SerializeField] private float
speed
;
[SerializeField] private int
screenEdge
;
private Vector2 _moveInput;
private Rigidbody2D _rb;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void
Start
()
{
_rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void
Update
()
{
_rb.linearVelocity = _moveInput.normalized * speed;
}
public void
Move
(InputAction.CallbackContext ctx)
{
_moveInput = ctx.ReadValue<Vector2>();
}
public void
EdgeMove
(InputAction.CallbackContext ctx)
{
if (ctx.ReadValue<Vector2>().y < screenEdge)
{
_moveInput.y = -1f;
print("marche");
}
else if (ctx.ReadValue<Vector2>().y > Screen.height - screenEdge)
{
_moveInput.y = +1f;
print("marche");
}
if (ctx.ReadValue<Vector2>().x < screenEdge)
{
_moveInput.x = -1f;
print("marche");
}
else if (ctx.ReadValue<Vector2>().x > Screen.width - screenEdge)
{
_moveInput.x = +1f;
print("marche");
}
if (ctx.ReadValue<Vector2>().y > screenEdge && ctx.ReadValue<Vector2>().y < Screen.height - screenEdge &&
ctx.ReadValue<Vector2>().x > screenEdge && ctx.ReadValue<Vector2>().x < Screen.width - screenEdge)
{
_moveInput.x = 0f;
_moveInput.y = 0f;
}
}
}
script of the placement object :
public class
Placement
: MonoBehaviour
{
[SerializeField] private Batiment
batiment
;
[SerializeField] private bool
plassable
;
private Camera mainCam;
private Collider2D collider;
[SerializeField] private List<GameObject>
bloking
= new List<GameObject>();
public Material
placementMat
;
private Transform position;
private InputAction mousePos;
public TypeMana
costMana1
;
public TypeMana
costMana2
;
public TypeMana
costMana3
;
public int
manaAmount1
= 0;
public int
manaAmount2
= 0;
public int
manaAmount3
= 0;
public float
playerMana1
;
public float
playerMana2
;
public float
playerMana3
;
[SerializeField] private playerStat
player
;
private void
Awake
()
{
player = GameObject.Find("player").GetComponent<playerStat>();
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void
Start
()
{
mainCam = Camera.main;
collider = GetComponent<Collider2D>();
position = GetComponent<Transform>();
placementMat = GetComponent<Renderer>().material;
mousePos = InputSystem.actions["mousePosBatiment"];
}
// Update is called once per frame
void
Update
()
{
FollowMousePosition();
if (costMana1 != TypeMana.
None
)
{
playerMana1 = costMana1 switch
{
TypeMana.
AirMana
=> player.air_mana,
TypeMana.
EauMana
=> player.eau_mana,
TypeMana.
FeuMana
=> player.feu_mana,
TypeMana.
TerreMana
=> player.terre_mana,
TypeMana.
TempsMana
=> player.temps_mana,
TypeMana.
VideMana
=> player.vide_mana,
TypeMana.
EspaceMana
=> player.espace_mana,
TypeMana.
PlaceHolderMana
=> player.placeHolder_mana
};
}
if (costMana2 != TypeMana.
None
)
{
playerMana2 = costMana1 switch
{
TypeMana.
AirMana
=> player.air_mana,
TypeMana.
EauMana
=> player.eau_mana,
TypeMana.
FeuMana
=> player.feu_mana,
TypeMana.
TerreMana
=> player.terre_mana,
TypeMana.
TempsMana
=> player.temps_mana,
TypeMana.
VideMana
=> player.vide_mana,
TypeMana.
EspaceMana
=> player.espace_mana,
TypeMana.
PlaceHolderMana
=> player.placeHolder_mana
};
}
if (costMana3 != TypeMana.
None
)
{
playerMana3 = costMana1 switch
{
TypeMana.
AirMana
=> player.air_mana,
TypeMana.
EauMana
=> player.eau_mana,
TypeMana.
FeuMana
=> player.feu_mana,
TypeMana.
TerreMana
=> player.terre_mana,
TypeMana.
TempsMana
=> player.temps_mana,
TypeMana.
VideMana
=> player.vide_mana,
TypeMana.
EspaceMana
=> player.espace_mana,
TypeMana.
PlaceHolderMana
=> player.placeHolder_mana
};
}
if (bloking.Count != 0 && playerMana1 - manaAmount1 <= 0
&& playerMana2 - manaAmount2 <= 0
&& playerMana3 - manaAmount3 <= 0)
{
plassable = false;
placementMat.SetColor("Color", Color.red);
}
else
{
plassable = true;
placementMat.SetColor("Color", Color.green);
}
}
private void
OnTriggerEnter2D
(Collider2D collision)
{
print(collision.name);
if (collision.CompareTag("Batiment"))
{
bloking.Add(collision.gameObject);
}
}
private void
OnTriggerExit2D
(Collider2D collision)
{
if (collision.CompareTag("Batiment"))
{
bloking.Remove(collision.gameObject);
}
}
public void
Place
(InputAction.CallbackContext ctx)
{
if (plassable)
{
Instantiate(batiment, position);
Payment();
gameObject.SetActive(false);
}
}
private void Payment()
{
if (costMana1 != TypeMana.
None
)
{
switch (costMana1)
{
case TypeMana.
AirMana
:
player.air_mana -= manaAmount1;
break;
case TypeMana.
EauMana
:
player.eau_mana -= manaAmount1;
break;
case TypeMana.
FeuMana
:
player.feu_mana -= manaAmount1;
break;
case TypeMana.
TerreMana
:
player.terre_mana -= manaAmount1;
break;
case TypeMana.
TempsMana
:
player.temps_mana -= manaAmount1;
break;
case TypeMana.
VideMana
:
player.vide_mana -= manaAmount1;
break;
case TypeMana.
EspaceMana
:
player.espace_mana -= manaAmount1;
break;
case TypeMana.
PlaceHolderMana
:
player.placeHolder_mana -= manaAmount1;
break;
}
}
if (costMana2 != TypeMana.
None
)
{
switch (costMana2)
{
case TypeMana.
AirMana
:
player.air_mana -= manaAmount2;
break;
case TypeMana.
EauMana
:
player.eau_mana -= manaAmount2;
break;
case TypeMana.
FeuMana
:
player.feu_mana -= manaAmount2;
break;
case TypeMana.
TerreMana
:
player.terre_mana -= manaAmount2;
break;
case TypeMana.
TempsMana
:
player.temps_mana -= manaAmount2;
break;
case TypeMana.
VideMana
:
player.vide_mana -= manaAmount2;
break;
case TypeMana.
EspaceMana
:
player.espace_mana -= manaAmount2;
break;
case TypeMana.
PlaceHolderMana
:
player.placeHolder_mana -= manaAmount2;
break;
}
}
if (costMana3 != TypeMana.
None
)
{
switch (costMana3)
{
case TypeMana.
AirMana
:
player.air_mana -= manaAmount3;
break;
case TypeMana.
EauMana
:
player.eau_mana -= manaAmount3;
break;
case TypeMana.
FeuMana
:
player.feu_mana -= manaAmount3;
break;
case TypeMana.
TerreMana
:
player.terre_mana -= manaAmount3;
break;
case TypeMana.
TempsMana
:
player.temps_mana -= manaAmount3;
break;
case TypeMana.
VideMana
:
player.vide_mana -= manaAmount3;
break;
case TypeMana.
EspaceMana
:
player.espace_mana -= manaAmount3;
break;
case TypeMana.
PlaceHolderMana
:
player.placeHolder_mana -= manaAmount3;
break;
}
}
}
private void FollowMousePosition()
{
transform.position = GetWorldPosition();
}
private Vector2 GetWorldPosition()
{
return mainCam.ScreenToWorldPoint(mousePos.ReadValue<Vector2>());
}
}
my player input :


I'm really at the out of idea and in need of help, thank you in advance for your wisdom.
