r/UnityHelp • • Apr 23 '25

My First Game :) Password: SolidDemo

Thumbnail whyt1.itch.io
0 Upvotes

r/UnityHelp • • Jun 01 '25

PROGRAMMING EasyCS Framework: Helps you to improve your Unity workflow!

Post image
0 Upvotes

Hey Unity devs,

I'm releasing EasyCS, a modular Entity-Component-Framework (ECF) for Unity - now at version v1.1.1.
I built EasyCS for myself, to structure the gameplay systems in the games I’m developing.
Now I’m open-sourcing it.

💡 What is EasyCS?

EasyCS is not another ECS clone, and it’s definitely not about chasing maximum performance benchmarks.

Entity-Component-Framework (ECF) offers structure, modularity, and separation of concerns - without forcing you to abandon MonoBehaviours or rewrite your entire codebase.

Unlike traditional ECS (where logic lives in global systems and entities are just IDs), ECF lets you:

  • 🔧 Define logic and data directly inside modular components

  • 🧩 Instantiate and configure entities via Unity prefabs

  • 📦 Leverage ScriptableObjects for templates and injection

  • 🧠 Use TriInspector to power an editor-friendly development experience

You still get the clarity and reusability of ECS - but with a shallower learning curve, full compatibility with Unity's ecosystem, and no mental gymnastics required.

Compare with standard Unity-approach: https://github.com/Watcher3056/EasyCS?tab=readme-ov-file#-framework-comparison-table

⚡️ Key benefits

  • ✅ Plug-and-play: Works in new AND mid-projects without total refactor

  • ✅ Optional DI support: Compatible with Zenject / VContainer

  • ✅ Prefab + ScriptableObject-based workflows

  • ✅ Editor-friendly tools with validation, nesting, visualization

  • ✅ Declarative data injection, no manual reference wiring

  • ✅ Loop-friendly architecture with native data access

  • ✅ MonoBehaviour reuse is fully supported — no rewriting needed

  • ✅ Easy conversion from existing MonoBehaviour-based systems

🧠 What it’s not

EasyCS isn’t built to compete with ECS in raw performance — and I won’t pretend it is.
If you’re simulating hundreds of thousands of entities per frame, use DOTS or custom ECS.
EasyCS gives you developer power, not raw throughput.

Performance is decent, but there’s still a lot of optimization work to do.

This framework is for:

  • Developers who want clean architecture without rewriting everything

  • Games that need structure, not simulation-scale optimization

  • Projects where editor tooling, prefab workflows, and iteration speed matter

🔗 Links

If you’re tired of MonoBehaviour chaos or ECS overkill — this might be what you’ve been looking for.

Would love to hear your thoughts — questions, critiques, suggestions, or even use cases you're tackling.
Feedback is fuel. 🔧🧠

I built it for my games.
Maybe it’ll help with yours.


r/UnityHelp • • Jun 13 '25

Why is my Player flying so fast when i walk up Slope

0 Upvotes

Hello i accsedently made my player in to a rocke. The problem appers when a walk up a Slop, i get shot up in the air with a speed from over 1000. Pleas help me i dont know waht to do anymore. Ok evry think workt this time here you have movment code and video:

using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class Movemt_player : MonoBehaviour
{
    [Header("Movment")]
    float speed;
    public float sprintspeed;
    public float walkspeed;

    public Text speedshower;

    public float groundDrag;

    public float jumpForce;
    public float jumpCooldown;
    public float airMultiplier;
    bool canjump = true;

    public float fallmutiplayer;

    public Transform orientation;

    [Header("Slide slope")]
    private float desiredMovespeed;
    private float lastdesiredMovespeed;
    public float slidespeed;
    private sliding sd;
    public bool issliding;
    private bool existingSlope;

    [Header("Key Binds")]
    public KeyCode jumpKey = KeyCode.Space;
    public KeyCode sprintkey = KeyCode.LeftShift;


    [Header("Slope")]
    public float maxSlpoeAngle;
    private RaycastHit slopehit;


    [Header("Ground")]
    public float playerHeight;
    public float grounddistance;
    public LayerMask ground;
    public bool grounded;
    public Transform groundcheck;

    float horizontalInput;
    float verticalInput;

    Vector3 moveDirection;

    Rigidbody rb;

    public MovementState state;

    public enum MovementState
    {
        Walking,
        sprinting,
        sliding,
        air
    }

    float geschwindichkeit;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.freezeRotation = true;
        sd = GetComponent<sliding>();

    }

    void Update()
    {
        grounded = Physics.CheckSphere(groundcheck.position, grounddistance, ground);
        SpeedControul();
        MyInput();
        Satethandler();


        if (!grounded)
        {
            rb.linearDamping = 0;
        }
        else
        {
            rb.linearDamping = groundDrag;
        }

        geschwindichkeit = rb.linearVelocity.magnitude;

        speedshower.text = geschwindichkeit.ToString();


    }

    private void FixedUpdate()
    {
        Movment();

        if (rb.linearVelocity.y < 0)
        {
            rb.AddForce(Vector3.down * fallmutiplayer, ForceMode.Force);
        }

    }

    private void MyInput()
    {
        horizontalInput = Input.GetAxisRaw("Horizontal");
        verticalInput = Input.GetAxisRaw("Vertical");

        if (Input.GetKey(jumpKey) && canjump && grounded)
        {
            canjump = false;

            Jump();

            Invoke(nameof(JumpReady), jumpCooldown);
        }
    }
    private void Satethandler()
    {
        if (issliding)
        {
            state = MovementState.sliding;

            if (OnSlope() && rb.linearVelocity.y < 0.1f)
            {
                desiredMovespeed = slidespeed;
            }
            else
            {
                desiredMovespeed = sprintspeed;
            }
        }

        if (grounded && Input.GetKey(sprintkey))
        {
            state = MovementState.sprinting;
            desiredMovespeed = sprintspeed;
        }
        else if (grounded)
        {
            state = MovementState.Walking;
            desiredMovespeed = walkspeed;
        }
        else
        {
            state = MovementState.air;
        }

        if (Mathf.Abs(desiredMovespeed - lastdesiredMovespeed) > 3f && speed != 0)
        {
            StopAllCoroutines();
            StartCoroutine(SmoothSpeed());

        }
        else
        {
            speed = desiredMovespeed;
        }


        lastdesiredMovespeed = desiredMovespeed;

    }

    private void Movment()
    {
        moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;

        if (OnSlope() && !existingSlope)
        {
            rb.AddForce(GetSlopeMoveDirection(moveDirection) * speed * 20f, ForceMode.Force);

            if (rb.linearVelocity.y > 0)
                rb.AddForce(Vector3.down * 80f, ForceMode.Force);
        }

        else if (grounded)
            rb.AddForce(moveDirection.normalized * speed * 10f, ForceMode.Force);
        else if (!grounded)
        {
            rb.AddForce(moveDirection.normalized * speed * 10f * airMultiplier, ForceMode.Force);
        }

        rb.useGravity = !OnSlope();

    }

    private void SpeedControul()
    {
        if(OnSlope() && !existingSlope)
        {
            if(rb.linearVelocity.magnitude > speed)
            {
                rb.linearVelocity = rb.linearVelocity * speed;
            }
        }

        else
        {
            Vector3 flatVel = new Vector3(rb.linearVelocity.x, 0f, rb.linearVelocity.z);

            if (flatVel.magnitude > speed)
            {
                Vector3 limitedVel = flatVel.normalized * speed;
                rb.linearVelocity = new Vector3(limitedVel.x, rb.linearVelocity.y, limitedVel.z);
            }
        }



    }

    private void Jump()
    {
        existingSlope = true;

        rb.linearVelocity = new Vector3(rb.linearVelocity.x, 0f, rb.linearVelocity.z);

        rb.AddForce(transform.up * jumpForce, ForceMode.Impulse);
    }

    private void JumpReady()
    {
        canjump = true;

        existingSlope = false;

    }

    public bool OnSlope()
    {
        if (Physics.Raycast(transform.position, Vector3.down, out slopehit, playerHeight * 0.5f + 0.3f))
        {

            float angle = Vector3.Angle(Vector3.up, slopehit.normal);
            return angle < maxSlpoeAngle && angle != 0;
        }

        return false;
    }

    public Vector3 GetSlopeMoveDirection(Vector3 direction)
    {
        return Vector3.ProjectOnPlane(direction, slopehit.normal).normalized;
    }

    private IEnumerator SmoothSpeed()
    {
        float time = 0;
        float difference = Mathf.Abs(desiredMovespeed - speed);
        float startValue = speed;

        while (time < difference)
        {
            speed = Mathf.Lerp(startValue, desiredMovespeed, time / difference);
            time += Time.deltaTime;
            yield return null;
        }

        speed = desiredMovespeed;
    }

}

r/UnityHelp • • Aug 03 '25

UNITY HELPP

0 Upvotes

Okay so I am trying to insert an image in my scene and it shows in it but when I "play" the game it doesn't show, I tried everything.


r/UnityHelp • • Feb 02 '26

Which AI is best for vibe coding a Unity game?

Thumbnail reddit.com
0 Upvotes

r/UnityHelp • • Jul 28 '25

Trying to make Brick Breaker in Unity 2022 version... But....

0 Upvotes

I did the code for the paddle movement, but when I press play, it just disappears. Why?


r/UnityHelp • • Oct 25 '25

PROGRAMMING Unity, VSC & Copilot - why does copilot not edit the files itself and instead asked me to copy n paste?

0 Upvotes

Hi, I use copilot (via chat plugin) in VSC for 2 weeks now and I am impressed with standalone python and c# projects I worked on. Meaning copilot editing files here and there.

But within a Unity project he just makes suggestion and I have to copy n paste. I think it's with all models that github copilot pro offers.

Do I something wrong?


r/UnityHelp • • Jun 30 '25

PROGRAMMING Level Selection Screen in Unity - Tutorial for Beginners

Thumbnail
youtu.be
0 Upvotes

r/UnityHelp • • May 18 '26

need help with my unity game on github pages

0 Upvotes

why is my game like this? the game like is wrongly sized or something and it just looks ugly


r/UnityHelp • • 4d ago

OTHER UnityPy?

0 Upvotes

Has anyone used UnityPy to extract models? If so how can I use UnityPy? I can't find a tutorial on how to use it.


r/UnityHelp • • Mar 07 '26

PROGRAMMING the soft body doesn't stop rotating

Post image
0 Upvotes

r/UnityHelp • • Apr 16 '25

Gameobject rotates without me wanting it to + 1 more

0 Upvotes

**1.**the object takes a different rotation without me wanting it to , i Think the problem is when it spawns not sure though . 2. the objects dont apear on the position they differ on if i look up or down , weird part is about both the problems that the collider stays kinda right. anyways here is the script:

public class currentweapons : MonoBehaviour
{ 
    public List<GameObject> currentweap = new List<GameObject>();  
    public Transform placeforweap;
    public int currentlyequipped = 0;
    public int currentequip= -1; // Index starts at 0
    public GameObject currentlyEquippedWeapon; // Stores the active weapon instance
    public GameObject magicbull;
    public Transform camera;
    public float hp = 100;


    // Start is called before the first frame update
    void Start()
    {
        currentlyEquippedWeapon = Instantiate(currentweap[0], placeforweap.position, placeforweap.rotation);
currentlyEquippedWeapon.transform.SetParent(camera);

    }

    // Update is called once per frame
    void Update()
    {
          { if (Input.GetButtonDown("turnmagic"))
       {
        Vector3 shootDirection = camera.forward;
        Instantiate(magicbull,placeforweap.position + shootDirection * 0.1f + new Vector3(0, 0, 2),placeforweap.rotation);
       }
        if (Input.GetButtonDown("cycle"))
        {  
            if (currentweap.Count > 0) // Ensure the list isn't empty
            { if(currentlyequipped==currentweap.Count-1)
        {
            currentlyequipped =0;
        }
          GameObject oldWeaponInstance = currentlyEquippedWeapon; // Store the instance of the currently equipped weapon

// Instantiate the new weapon
GameObject newWeapon = Instantiate(currentweap[currentlyequipped + 1], placeforweap.position, Quaternion.identity);
newWeapon.transform.SetParent(camera); // Attach to the weapon holder

// Update the reference to the currently equipped weapon
currentlyEquippedWeapon = newWeapon;

// Destroy the old weapon instance (not the prefab!)
if (oldWeaponInstance != null)
{
    Destroy(oldWeaponInstance);
}

// Update the currently equipped index
currentlyequipped = currentlyequipped + 1;
currentequip = currentlyequipped;
               
             
             
            }
        }
    }

}
       public void TakeDamage(float damage)
    {
        hp = hp-damage;
        
    }
}

r/UnityHelp • • Jan 30 '26

UNITY unity hub "something went wrong. please sign in again"

0 Upvotes

just give me every solution under the sun so that i can use all of them and be fully aware that my problem wont be fixed.


r/UnityHelp • • Sep 19 '26

UE Fatal Error 107

Post image
0 Upvotes

r/UnityHelp • • Aug 05 '26

What is this error, and should I be worried about it?

Post image
0 Upvotes

r/UnityHelp • • Oct 20 '25

hair mesh messed up when import to unity

Thumbnail gallery
0 Upvotes

Hi, im new to unity, my model hair mesh all messed up when i import the fbx file into unity


r/UnityHelp • • Jul 07 '26

UNITY How to learn unity coding?

Thumbnail reddit.com
0 Upvotes

r/UnityHelp • • Aug 14 '26

OTHER Any tips for post processing?

0 Upvotes

Although I’m still in the process of learning all of game development, I’m a bit more comfortable designing and programming than I am with anything art related. It’s finally time to make my game have the warm jovial feel that I envisioned it having.

Did I hit the mark, or is there something I’m complete misunderstanding?


r/UnityHelp • • Jun 11 '25

Really bad break

0 Upvotes

I have been trying for days, but there's an issue with my render and TMP, I can't get my game to render my camera no mater what...the shader works fine in everything else, I can show stuff with dms or what ever, bur I out of ideas


r/UnityHelp • • Jul 31 '26

UNITY How do I find the 3D model inside this unity package?

0 Upvotes

Hello! this is my first ever time using unity or having any experience with 3D modelling and I've given up all hope. I play VR Chat with my friends some days but I've never really had an avatar I liked so I bought the base of the avatar I used the most in a unity package so I could modify it and have an avatar I liked, but I've been trouble shooting for the past four days on where to find the avatar and I cant find it in the pack anywhere please helppp :(((


r/UnityHelp • • Sep 25 '26

I hate unity

Thumbnail reddit.com
0 Upvotes

How do I make a sword for blade and sorcery


r/UnityHelp • • May 11 '26

PROGRAMMING Voxel Mesh Not Displaying Properly

0 Upvotes

Good evening!

I am working on a voxel engine for an idea I am tossing around, but I am encountering a problem. Basically what should be happening is a column of “Dirt” blocks should be generating, with only the exposed faces rendering. To test this, I have placed some “Air” blocks in the column via the block data generation job. After the block data is generated, the mesh generation job takes over and populates a couple native arrays, two of which matter here: vertices and triangles. I know the data in these arrays is accurate as I have used the debug “DrawLine” function to draw a set of lines between the final four points in the vertices array (as shown in the attached picture as a white square made up of two white rectangles). However, the column that is generated exhibits a couple problems. First, it does not extend all the way to the top of the chunk height, even though the data confirms that it should. Second, for the first 20 or so rows, random bits of extra geometry are present that make no sense when compared with the data I know the vertices and triangles arrays to be holding. Can someone please take a look at attached picture and code (which is a work in progress, so I apologize for the comments and such) and let me know what I have missed? I am beating myself up over this.

using Unity.Collections;
using Unity.Jobs;
using UnityEngine;


public struct MeshDataJob : IJob
{
    public NativeArray<BlockType> blockTypes;
    public NativeList<Vector3> vertices;
    public NativeList<int> triangles;
    public NativeList<Vector2Int> UVs;
    public int worldWidth;
    public int worldHorizontalArea;
    public int worldVolume;


    public NativeArray<Vector3> verticesArray;
    public NativeArray<int> vertexCount;
    public NativeArray<int> triangleArray;
    public NativeArray<int> triangleCount;


    private Vector3 currentCoords;
    private Vector3 checkCoords;


    public void Execute()
    {
        currentCoords = Vector3.zero;
        checkCoords = Vector3.zero;
        
        for (int blockIndex = 0; blockIndex < blockTypes.Length; blockIndex++)
        {
            // If the current block is air, skip.
            if (BlockType.Air.Equals(blockTypes[blockIndex])) { continue; }
            
            // Get coords for current index.
            currentCoords = IndexToVector3(blockIndex);
            
            // Get exposed faces.
            /*
                Render face if block is facing one of the following:
                - Air
                - Top
            */
            for (int faceIndex = 0; faceIndex < 6; faceIndex++)
            {
                if (!(faceIndex == 0
                    || faceIndex == 1
                    || faceIndex == 2
                    || faceIndex == 3
                    || faceIndex == 4
                    || faceIndex == 5
                )) { continue; }
                
                int checkIndex = 0;
                /*
                    0 - top
                    1 - left
                    2 - front
                    3 - right
                    4 - rear
                    5 - bottom
                */
                switch (faceIndex)
                {
                    case 0:
                        checkIndex = blockIndex + worldHorizontalArea;
                        
                        checkCoords = IndexToVector3(checkIndex);
                        if (currentCoords.x != checkCoords.x || currentCoords.z != checkCoords.z) { continue; }
                        break;
                    case 1:
                        checkIndex = blockIndex - 1;


                        checkCoords = IndexToVector3(checkIndex);
                        if (checkIndex < 0 || currentCoords.y != checkCoords.y || currentCoords.z != checkCoords.z) { continue; }
                        break;
                    case 2:
                        checkIndex = blockIndex + worldWidth;


                        checkCoords = IndexToVector3(checkIndex);


                        if (currentCoords.y != checkCoords.y || currentCoords.x != checkCoords.x) { continue; }
                        break;
                    case 3:
                        checkIndex = blockIndex + 1;


                        checkCoords = IndexToVector3(checkIndex);
                        if (currentCoords.y != checkCoords.y || currentCoords.z != checkCoords.z) { continue; }
                        break;
                    case 4:
                        checkIndex = blockIndex - worldWidth;


                        checkCoords = IndexToVector3(checkIndex);
                        if (checkIndex < 0 || currentCoords.y != checkCoords.y || currentCoords.x != checkCoords.x) { continue; }
                        break;
                    case 5:
                        checkIndex = blockIndex - worldHorizontalArea;


                        checkCoords = IndexToVector3(checkIndex);
                        if (checkIndex < 0 || currentCoords.x != checkCoords.x || currentCoords.z != checkCoords.z) { continue; }
                        break;
                }


                // If the adjacent block is within the column and not air, do not render it.
                if (checkIndex < worldVolume && !BlockType.Air.Equals(blockTypes[checkIndex])) { continue; }


                /*
                    Below logic should only fire for the following faces:
                    - Top faces at the top of the chunk.
                    - Any face on a non-air block facing an air block.
                */
                switch (faceIndex)
                {
                    case 0:
                        // vertices.Add(currentCoords + new Vector3(0, 1, 0)); // 1
                        // vertices.Add(currentCoords + new Vector3(0, 1, 1)); // 3
                        // vertices.Add(currentCoords + new Vector3(1, 1, 1)); // 6
                        // vertices.Add(currentCoords + new Vector3(1, 1, 0)); // 2


                        verticesArray[vertexCount[0] + 0] = (currentCoords + new Vector3(0, 1, 0));
                        verticesArray[vertexCount[0] + 1] = (currentCoords + new Vector3(0, 1, 1));
                        verticesArray[vertexCount[0] + 2] = (currentCoords + new Vector3(1, 1, 1));
                        verticesArray[vertexCount[0] + 3] = (currentCoords + new Vector3(1, 1, 0));
                        vertexCount[0] = vertexCount[0] + 4;
                        break;
                    case 1:
                        // vertices.Add(currentCoords + new Vector3(0, 0, 1));
                        // vertices.Add(currentCoords + new Vector3(0, 1, 1));
                        // vertices.Add(currentCoords + new Vector3(0, 1, 0));
                        // vertices.Add(currentCoords + new Vector3(0, 0, 0));


                        verticesArray[vertexCount[0] + 0] = (currentCoords + new Vector3(0, 1, 0));
                        verticesArray[vertexCount[0] + 1] = (currentCoords + new Vector3(0, 1, 1));
                        verticesArray[vertexCount[0] + 2] = (currentCoords + new Vector3(1, 1, 1));
                        verticesArray[vertexCount[0] + 3] = (currentCoords + new Vector3(1, 1, 0));
                        vertexCount[0] = vertexCount[0] + 4;
                        break;
                    case 2:
                        // vertices.Add(currentCoords + new Vector3(1, 0, 1));
                        // vertices.Add(currentCoords + new Vector3(1, 1, 1));
                        // vertices.Add(currentCoords + new Vector3(0, 1, 1));
                        // vertices.Add(currentCoords + new Vector3(0, 0, 1));


                        verticesArray[vertexCount[0] + 0] = (currentCoords + new Vector3(1, 0, 1));
                        verticesArray[vertexCount[0] + 1] = (currentCoords + new Vector3(1, 1, 1));
                        verticesArray[vertexCount[0] + 2] = (currentCoords + new Vector3(0, 1, 1));
                        verticesArray[vertexCount[0] + 3] = (currentCoords + new Vector3(0, 0, 1));
                        vertexCount[0] = vertexCount[0] + 4;
                        break;
                    case 3:
                        // vertices.Add(currentCoords + new Vector3(1, 0, 0));
                        // vertices.Add(currentCoords + new Vector3(1, 1, 0));
                        // vertices.Add(currentCoords + new Vector3(1, 1, 1));
                        // vertices.Add(currentCoords + new Vector3(1, 0, 1));


                        verticesArray[vertexCount[0] + 0] = (currentCoords + new Vector3(1, 0, 0));
                        verticesArray[vertexCount[0] + 1] = (currentCoords + new Vector3(1, 1, 0));
                        verticesArray[vertexCount[0] + 2] = (currentCoords + new Vector3(1, 1, 1));
                        verticesArray[vertexCount[0] + 3] = (currentCoords + new Vector3(1, 0, 1));
                        vertexCount[0] = vertexCount[0] + 4;
                        break;
                    case 4:
                        // vertices.Add(currentCoords + new Vector3(0, 0, 0));
                        // vertices.Add(currentCoords + new Vector3(0, 1, 0));
                        // vertices.Add(currentCoords + new Vector3(1, 1, 0));
                        // vertices.Add(currentCoords + new Vector3(1, 0, 0));


                        verticesArray[vertexCount[0] + 0] = (currentCoords + new Vector3(0, 0, 0));
                        verticesArray[vertexCount[0] + 1] = (currentCoords + new Vector3(0, 1, 0));
                        verticesArray[vertexCount[0] + 2] = (currentCoords + new Vector3(1, 1, 0));
                        verticesArray[vertexCount[0] + 3] = (currentCoords + new Vector3(1, 0, 0));
                        vertexCount[0] = vertexCount[0] + 4;
                        break;
                    case 5:
                        // vertices.Add(currentCoords + new Vector3(0, 0, 1));
                        // vertices.Add(currentCoords + new Vector3(0, 0, 0));
                        // vertices.Add(currentCoords + new Vector3(1, 0, 0));
                        // vertices.Add(currentCoords + new Vector3(1, 0, 1));


                        verticesArray[vertexCount[0] + 0] = (currentCoords + new Vector3(0, 0, 1));
                        verticesArray[vertexCount[0] + 1] = (currentCoords + new Vector3(0, 0, 0));
                        verticesArray[vertexCount[0] + 2] = (currentCoords + new Vector3(1, 0, 0));
                        verticesArray[vertexCount[0] + 3] = (currentCoords + new Vector3(1, 0, 1));
                        vertexCount[0] = vertexCount[0] + 4;
                        break;
                }
                
                // Triangles
                // int vertexIndex = vertices.Length - 4;
                // triangles.Add(vertexIndex + 0);
                // triangles.Add(vertexIndex + 1);
                // triangles.Add(vertexIndex + 3);
                // triangles.Add(vertexIndex + 3);
                // triangles.Add(vertexIndex + 1);
                // triangles.Add(vertexIndex + 2);


                int vertexArrayIndex = vertexCount[0] - 4;
                triangleArray[triangleCount[0] + 0] = vertexArrayIndex + 0;
                triangleArray[triangleCount[0] + 1] = vertexArrayIndex + 1;
                triangleArray[triangleCount[0] + 2] = vertexArrayIndex + 3;
                triangleArray[triangleCount[0] + 3] = vertexArrayIndex + 3;
                triangleArray[triangleCount[0] + 4] = vertexArrayIndex + 1;
                triangleArray[triangleCount[0] + 5] = vertexArrayIndex + 2;
                triangleCount[0] = triangleCount[0] + 6;


                // if (blockIndex >= 90880) { Debug.Log(triangleArray.GetSubArray(triangleCount[0] - 6, triangleCount[0]).ToArray().ToString()); }


                // UV
                UVs.Add(new Vector2Int(0, 0));
            }
        }
    }


    private Vector3 IndexToVector3(int index)
    {
        Vector3 vector = Vector3.zero;
        vector.y = index / worldHorizontalArea;
        vector.z = (index % worldHorizontalArea) / worldWidth;
        vector.x = (index % worldHorizontalArea) % worldWidth;


        return vector;
    }


    private int Vector3ToIndex(Vector3 vector)
    {
        int index = 0;
        index += (int)vector.y * worldHorizontalArea;
        index += (int)vector.z * worldWidth;
        index += (int)vector.x;


        return index;
    }
}

r/UnityHelp • • Apr 16 '26

SOLVED AR Image Tracking - Camera problem

0 Upvotes

Hello! I'm a complete beginner in Unity. I'm trying to make an image tracking AR. Just a simple AR, where if I point the camera at the image, the model will appear. No animation, no tricks, just let it appear. I have Unity version 2022.3. The computer does not support a higher version (This is a serious 4GB RAM computer 😅).

I'm doing it in AR Mobile Template, where I deleted the Raycast Manager, the Plane Manager, the Object Spawner, so that the built-in AR game would not appear. Maybe I deleted something important with this?

In the middle of the video you can see what was left in the Hierarchy, Inspector.

I also tried in plain 3D Universal. I added the AR Session, XR Origin separately, set up the AR Tracked Image Manager separately, added the necessary things, but then the screen was black, even though the AR Camera and Camera Background were there.

I'm building on Android, my phone is Redmi note 9Pro. This will not be a published application, but just a test for myself.

When the application starts, everything is fine at first, then when I hold the phone to the image, the model appears, but with it the Unity environment and I am not returned to reality.

Please help.


r/UnityHelp • • Aug 12 '23

PROGRAMMING Code Review

Thumbnail
gallery
0 Upvotes

I am going through a tutorial on AR watch try on. I found it that I could write this code in a shorter way by introducing a list for storing watch models and creating a common function, which will be called when clicked on a button with respective watch images.

This is a small project, only has 3 watch models. But what if it had many models to choose from? So I searched for codes which I found uselful.

Is there anything wrong with my approach? Or is there anything else I could have tried.

Also I'm passing reference number(watchRefID) from each button(same number as the model's index in the watchModels list) so that I can set only that model as active and others disabled.

I have recently learned that local variables declared inside a method is a bad practise, because each time the method gets called a new copy of that variable gets created. Is this same for parameters inside a method?

Thanks in advance.(Have a toffee 🍬, since you took the patience to read my paragraphs🥺🥹)