r/Unity3D – Telegram
r/Unity3D
265 subscribers
12.7K photos
15.6K videos
14 files
48.1K links
News about the Unity engine and project showcases from Reddit. Made possible with @reddit2telegram (@r_channels).
Download Telegram
Question about unity

So im making a game with my friend, i couldn't get our stuff to sync so we are doing that i do a part of the game, then put it on a usb stick and give it to him.

But if my game has assets bought from the store will he have any problems with it? (they are free assets btw)

Or does he have to buy the assests before starting the project or something?


https://redd.it/1giki4s
@r_Unity3D
Having issue snapping a gameobject to a point

Hi there,

Would somebody be able to tell me why this doesn't work?

    public void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "Grid")
        {
            Debug.Log("Creature has been snapped");
            transform.position = col.gameObject.transform.localPosition;
        }
    }

I'm trying to move the gameObject this noscript is attached to to the transform.position of the gameobject the collider 'col' is attached to.

The intended behaviour is that you drag the gameobject inside a trigger with your mouse and then it snaps to the center of the gameobject the trigger is attached to.

The Debug.Log triggers here but the "transform.position = col.gameObject.transform.localPosition;" line is doing nothing.


Any help would be appreciated. Thank you.

https://redd.it/1gio47z
@r_Unity3D
[Unity 2022.3.22f1] How to overlay a static texture on a sprite that uses a spritesheet with ShaderGraph?

Hey there, I’m trying to accomplish something I thought pretty basic: I want to overlay a static wire texture on a sprite that uses a spritesheet. The end result should look like this:

[Expected result](https://preview.redd.it/9xnpjl60opyd1.png?width=185&format=png&auto=webp&s=fcc72e81cae2e0230628d152c3fbb7458b7d47e3)

I’m simply using a Tiling and Offset node to tile a simple cross texture (7x7 pixels), then use a Lerp to add it to the base sprite.
Note that the sprite is part of a big spritesheet.



The issue is that I cannot find the right way to provide UV to the Tiling and Offset node, every possibility has issues:

* Using “Position - Object” works well when the sprite is static, but when it moves the checker pattern slides across the sprite

[Grid sliding when sprite moves](https://i.redd.it/e4perrz2opyd1.gif)

* Using Screen space or World space position does not achieve what I want, as the checker pattern should stay static on the sprite even when it moves
* Using the UV0 - UV3 does not work as the sprite is part of a spritesheet, so when the animation plays the UV change and therefore the checker pattern moves

[Grid moving when animation plays](https://i.redd.it/l82n2g76opyd1.gif)

Any suggestion of having this checker pattern always be static on top of the sprite?

https://redd.it/1giqfgy
@r_Unity3D
Media is too big
VIEW IN TELEGRAM
Tower Factory, the tower defense/factory sim I've been solo developing for the last 16 months will release next week!

https://redd.it/1ginb08
@r_Unity3D
Besoin d'aide pour créer un système d'inventaire dans Unity2D (avec noscript fourni)

Salut tout le monde,

Je suis en train de développer un jeu 2D dans Unity et j'ai besoin de conseils pour créer un système d'inventaire. J'ai déjà mis en place quelques noscripts pour gérer des interactions telles que la collecte et la coupe d'arbres, mais je suis débutant en noscripting et je ne sais pas trop si je suis sur la bonne voie.

# Mes noscripts actuels :

1. **Woodcutting.cs** : Ce noscript gère la coupe des arbres, la création d'items (comme des bûches) via des prefabs, l'ajout d'expérience au joueur et le respawn des arbres.
2. **PickupItem.cs** : Un noscript attaché aux objets ramassables pour gérer l'interaction et récupérer les données de l'item.
3. **ItemData.cs** : Un ScriptableObject que j'utilise pour définir des outils. Voici le noscript complet :

​

csharpCopier le codeusing UnityEngine;

[CreateAssetMenu(fileName = "New Item", menuName = "Inventory/Item")]
public class ItemData : ScriptableObject
{
public string itemName; // Nom de l'item
public Sprite itemIcon; // Icône de l'item
public string toolType; // Type de l'outil, ex : "Axe", "Pickaxe", etc.
public int toolPower; // Puissance de l'outil (utile pour le woodcutting)

// Nouvelles variables ajoutées
public bool isStackable; // Indique si l'item peut être empilé
public int maxStackSize; // Taille maximale de la pile, par exemple 10, 20, etc.
}


# Mon objectif :

Je souhaite créer un inventaire où les items collectés (comme des bûches) apparaissent et peuvent être gérés. Actuellement, mon `ItemData` est principalement utilisé pour des outils, mais j'aimerais savoir si je devrais le structurer différemment pour gérer des ressources ou d'autres types d'items.

# Mes questions :

* **Est-ce que mon** `ItemData.cs` **est bien structuré pour être utilisé comme base pour un inventaire général ?**
* **Y a-t-il une meilleure façon de gérer différents types d'items dans l'inventaire ?**
* **Des conseils sur la façon de gérer l'affichage, l'empilement, et l'interaction des items dans l'inventaire ?**

Tout conseil, suggestion ou exemple de code serait très apprécié ! Je débute dans le développement, donc n'hésitez pas à expliquer même les concepts de base.

Merci d'avance pour votre aide !

https://preview.redd.it/z25jn9j94ryd1.png?width=1920&format=png&auto=webp&s=d0426f435ee3667fccb8af6e800d0bab2c4d87f8

https://preview.redd.it/imqi0aj94ryd1.png?width=1920&format=png&auto=webp&s=e3de30c94fc858666fd919fec37c7a1946000a07



https://redd.it/1gix8ic
@r_Unity3D
Need help creating an inventory system in Unity2D (with provided noscript)

Hi everyone,

I'm currently developing a 2D game in Unity and need some advice on creating an inventory system. I've already set up some noscripts to manage interactions like gathering and chopping trees, but I'm a beginner at noscripting and am not entirely sure if I'm on the right track.

My current noscripts: Woodcutting.cs: This noscript handles tree chopping, item creation (e.g., logs) through prefabs, adding experience to the player, and tree respawning.

PickupItem.cs: A noscript attached to collectible objects to handle interactions and retrieve item data.

ItemData.cs: A ScriptableObject I use to define tools. Here is the complete noscript:

csharpCopier le codeusing UnityEngine;

CreateAssetMenu(fileName = "New Item", menuName = "Inventory/Item")
public class ItemData : ScriptableObject
{
public string itemName; // Name of the item
public Sprite itemIcon; // Item icon
public string toolType; // Type of the tool, e.g., "Axe", "Pickaxe", etc.
public int toolPower; // Power of the tool (useful for woodcutting)

// New variables added
public bool isStackable; // Indicates if the item can be stacked
public int maxStackSize; // Maximum stack size, e.g., 10, 20, etc.
}


My goal: I want to create an inventory where collected items (like logs) appear and can be managed. Currently, my ItemData is mainly used for tools, but I'd like to know if I should structure it differently to manage resources or other types of items.

My questions:

1. Is my ItemData.cs well-structured to be used as a base for a general inventory?
2. Is there a better way to manage different types of items in the inventory?
3. Any advice on how to handle item display, stacking, and interaction in the inventory?

Any advice, suggestions, or code examples would be greatly appreciated! I'm new to development, so feel free to explain even the basic concepts.

Thanks in advance for your help!

https://preview.redd.it/m07z7i6hnryd1.png?width=1920&format=png&auto=webp&s=2d651a131b17245d4e6febd0bca5b49a5009c0dc

https://preview.redd.it/9xd95j6hnryd1.png?width=1920&format=png&auto=webp&s=0f4934beebe94d9c5635747abeaedfe025181ca1



https://redd.it/1gizoe8
@r_Unity3D
What was your "roadmap" that you followed to learn the Unity Engine? What did you do (what Videos, what courses, what habits etc. did you follow) to become an Intermediate/Advanced coder?

Im currently in this very narrow space where i just cant find alot of ways to escape being a beginner coder. So im interested to hear what you guys did to become better. And perhaps what examples there are that helped you speed up your journey when it comes to OOP.

https://redd.it/1giwia8
@r_Unity3D