#archived-code-general

1 messages ยท Page 439 of 1

north cypress
#

Alright sir, again I only sent a pic of the screens as my pc bugged the fuck out, but I'll use those pastebim things instead of screenshot from now on

#

Appreciate yall help

zinc tartan
#

i need to have an object be "parented" to another object, have its rotation and position change relative to its "parent" without actually being parented to the other object i believe the best solution for this is to have an offset and changing the "childs" position based on the offset. this is the code i tried and i fully understand why this code doesnt work but i just cant seem to wrap my head around how to apply the solution to make it work

private void FixedUpdate()
    {
        var pos = transform.position;
        _offset.x = Mathf.Abs(pos.x - parent.transform.position.x);
        pos.x += _offset.x;
        transform.position = pos;
    }```
cosmic mica
#

aight so uhm how can I improve this?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class CharacterAnimations : MonoBehaviour
{


    private Animator CharacterAnimator;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        CharacterAnimator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        if (CharacterAnimator != null)
        {
            if (Input.GetKeyDown(KeyCode.W))
            {
                CharacterAnimator.SetTrigger("TrRun");
            }

            if (Input.GetKeyUp(KeyCode.W))
            {
                CharacterAnimator.SetTrigger("TrStop");
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                CharacterAnimator.SetTrigger("TrRunBackwards");
            }
            if (Input.GetKeyUp(KeyCode.S))
            {
                CharacterAnimator.SetTrigger("TrStop");
            }
            if (Input.GetKeyDown(KeyCode.D))
            {
                CharacterAnimator.SetTrigger("TrRun");
            }

            if (Input.GetKeyUp(KeyCode.D))
            {
                CharacterAnimator.SetTrigger("TrRun");
            }
            if (Input.GetKeyDown(KeyCode.A))
            {
                CharacterAnimator.SetTrigger("TrRunBackwards");
            }
            if (Input.GetKeyUp(KeyCode.A))
            {
                CharacterAnimator.SetTrigger("TrStop");
            }
        }
    }
}
cosmic mica
naive swallow
steady bobcat
steady bobcat
cosmic mica
#

I have no idea what that means but the game is 3d

steady bobcat
#

HA okay go read the page and then come back

cosmic mica
#

oh I have heard about blend trees

steady bobcat
#

These should be used instead of the crud you showed above.
e.g. input horizontal + vertical to blend between forward/back/left/right movement anims

#

i think the unity pre made examples use these

naive swallow
steady bobcat
#

no, the doc page explains it....

cosmic mica
#

oh I didnt see it

#

thanks

#

im gonna sleep now ill fix it tmrw

steady bobcat
#

๐Ÿ˜

cosmic mica
#

its 2 am

rigid island
steady bobcat
#

yes yes have a sleep and come back with a fresh mind

toxic vault
#

Any way to make this happen with TextMeshPro? Like different colors and sizes within a sentence? Maybe with icons in it as well?

rigid island
#

for sprite is just <sprite> but you can scroll through list there is so much you can do including clickable links

steady bobcat
#

I presume ui toolkit can do this even better with <span> ?

toxic vault
#

Awesome, thank you!!! So the tag just go in the textmeshpro text box itself?

rigid island
#

would assume if it works like CSS.. hmm I need to start messing with UIToolkit again besides Editor utils/assets

rigid island
#

TMP internally parses the tags

toxic vault
#

Perfect!! Thank you!!

zinc parrot
#

yeah ok so calling this in builds on a mesh that is NOT readwrite errors:

leaden ice
zinc parrot
leaden ice
#

What game functionality or system are you trying to set up that you need to do this?

zinc parrot
#

I just need to be able to load meshes in builds
its for a plugin/asset I am working on, and I dont want to require the user to set all meshes to be readwrite all the time, even procedural meshes

#

especially since some meshes you cant change that on(some GLB importers you have to modify the importers code of to get their meshes to be readwrite)

leaden ice
#

But it seems like you need to read the mesh data, so wouldn't requiring the mesh to be read/write be a reasonable requirement?

#

You could also have your plugin set it to read/write in the editor (perhaps with some warning, or prompt, or user action to ask for permission)

zinc parrot
#

it just really seems like there SHOULD be a way to read non readwrite meshes in builds
in editor play mode, I can do GPU -> CPU readback, why cant I do that in builds tho?

#

it just seems really weird that an important part of reading meshes on the GPU for rasterization seemingly doesnt exist in builds

leaden ice
zinc parrot
#

you cant change that from script afaik without creating a new mesh, copying the data, disposing of the old mesh, and saving the new mesh, which feels like itll cause hell in terms of asset linking, could mess with custom importers(especially if you import from blender directly and modify the blender file later) and could take a LOT of ram

zinc parrot
#

ewwww

#

thats a nasty workaround

#

if the mesh is readwriteable I can get the indexbuffer tho I think,

#

so I can at least handle skinned meshes like that

#

but still

leaden ice
zinc parrot
#

for reference, this is how I get the index buffer, where TempFilter is a MeshFilter that is known valid:

                    mesh = TempFilter.sharedMesh;
                    mesh.indexBufferTarget |= GraphicsBuffer.Target.Raw;
                    GraphicsBuffer indexesBuffer = mesh.GetIndexBuffer();
zinc parrot
#

but yeah it doesnt say anywhere in the api documentation that indexbuffers dont exist for non readwrite meshes in builds

leaden ice
zinc parrot
#

urg
it just feels like it would be a workaround solution when there really should be an easier way

#

I cant believe tho I am the only one to run into this issue it seems, really makes me feel like there IS a good solution that I just dont know about
the only post relating to this is my own post from two years ago on reddit

#

there IS GetNativeIndexBufferPtr

#

but can that be resolved back to a graphics buffer in unity?

cyan quarry
#

How do people handle "block durability" in voxel games?

I don't really care for blocks "saving" their durability in the chunk data itself.

My idea was to spawn a 1.01 scaled voxel inside a voxel with the "animation" texture whenever you first click it.
If you click it again, it subtracts from its HP.
Once its zero, it deletes the animation block, as well as block it spawned inside.

Im doing this with an indicator as well. Just hiding/showing instead of deleting.

Is there an easier and/or better way to do this?

cyan quarry
#

ok this will be fine. I dont really care if theres another solution anymore tbh lol.

worst case scenerio, I have 20+ blocks that are in the "breaking" stage.
A block will only hold its durability for a few seconds before it "heals" itself and deletes the "block breaking" gameobject.

I just need to use a shared material for each "block break", and offset the texture by its current stage

night harness
#

Not sure where to ask but this is more-so just a curiosity about Unity that I know at this point they absolutely can't do

Given that tags and layermask definitions are so hardcoded and can't be adjusted at runtime, Would it have been reasonable at some point for Unity to automatically generate and manage a c# definition for this to be referenced explicitly in code rather than constant juggling of ints and strings?

#

Or is that a fairly outrageous pitch in the context of more sophisticated programming

stable osprey
#

Outrageous.

stable osprey
night harness
#

that's somewhat what i meant yeah

stable osprey
#

yeah what I mean is we do this already ๐Ÿ˜› Pretty much every game has this class in one form or another, and I was recommending you do this too.

thick terrace
night harness
#

Respectfully wasn't asking for a solution ๐Ÿ˜› It's not a problem I have

#

Just was curious on why Unity may not have

stable osprey
#

Gotcha. I'd say it's overengineering. Saves maybe 5 minutes per project, and adds an additional dependency (the auto-generated code)

thick terrace
#

there's stuff like do you want every layer/tag change to trigger a domain reload, or do you need to worry about syncing it manually and it going out of sync, which they don't have to care about if they just let you implement it yourself

fleet gorge
#

Your scaled voxel is also a good idea

leaden ice
cyan quarry
leaden ice
#

so it's just two variables

#

but yeah that dictionary approach sounds efficient

cyan quarry
#

Yeah I'm pretty sure MC just cares about the block you're viewing per tick.

I want stuff like "explosions" that literally simulate the explosion itself, leaving a damaged crator.

Or blocks that could "burn" to death showing durability.

#

Mining isn't even the main idea of my game lol. But I figure i might as well develop the sandbox a bit now vs later.

leaden ice
#

For any kind of per-voxel data you always have essentially two choices:

  • a 2D array
  • a Dictionary.

The Dictionary is better for sparsely populated data and the array is better for densely populated data. This durability thing sounds very sparse.

inner yarrow
#

Is there anyway to do something like this where it doesn't get messed up down the road by i being in there? Basically I need a way for it to convert i into a primitive integer in the function, so that it can actually be called later outside of this loop and without using the final value of i for all the actions.

somber nacelle
leaden ice
inner yarrow
#

That feels super dumb to do, but it worked, so thank you!

chilly surge
#

Turns out the issue has nothing to do with URP/camera/changing values at runtime/etc, but instead the custom UI shader is missing:

ZTest [unity_GUIZTestMode]

It doesn't seem to be documented anywhere and the effect of missing it is very subtle, only causing shader to not work under very specific circumstances, which caused me to think it was the code triggering those circumstances to be broken, but it's actually the shader all along and it just happened to not show symptoms until now.

forest hull
#

Got scheduled for tools programmer interview. I have some experience in .Net (Asp.net mvc, Xamarin Mvvm, Winforms ) and QA roles and have made some games in Unity during my career gap. I just want to know that whether the interviews are tough and what are the questions that I might face? Need some advice if any.

glossy ledge
#

So I am remaking King of Crokinole (was my 1st game and it would cost more time to fix than to rebuild) ... One of the things that messed things up were these forced engine upgrades I had to do to comply wit Google Play &Apple policies (billing libraries and such)... so I was wondering if and if so how I could have these platform specific upgrades outside of the main app (like addressables or even separate packages) ... also these build levels (for Android are a right pain)... I mean how do the pro's deal with this?
Anyway enjoy a w.i.p. as well

glossy ledge
robust dome
#
 Vector3 moveDir = transform.forward * moveAction.ReadValue<Vector2>().y + transform.right * moveAction.ReadValue<Vector2>().x;
 rb.velocity = moveDir * movementSpeed;

trying to put the rb.velocity.y into this fps movement line, how would i go about this?

#

because rn it only falls down really slow because there is no y axis defined here

mellow sigil
#
Vector3 velocity = moveDir * movementSpeed;
velocity.y = rb.velocity.y;
rb.velocity = velocity;
robust dome
#

works! thank you vm Nitku.

maiden trellis
#

how to make some sort of a temperature map on a 2D grid?

stable osprey
maiden trellis
#

so the 'cells' could react to hot zones

stable osprey
#

ah. Well, you can either make a custom tile that accepts a Temperature parameter, or use custom OnCellEntered logic.

maiden trellis
#

i want tilemaps because cooking phones is not in my plans...

stable osprey
#

cooking phones? ๐Ÿ˜†

#

yeah anyway check out custom tiles!

maiden trellis
#

and +mp....

#

so how i could sync it?

stable osprey
#

well, how do you sync other stuff? e.g. Health?

maiden trellis
#

but im mp rookie...

maiden trellis
stable osprey
#

try float[][] then

maiden trellis
maiden trellis
stable osprey
#

cmon man you can figure this out by yourself -- google How to init 2D float array

#
float[][] temperatureMap = new float[gridX][];
for (int i = 0; i < gridX; i++) { temperatureMap[i] = new float[gridY]; }
young abyss
#

how to setup gitlab CI with build and unit tests for a unity project?

last palm
#

guys i try to teach and i find flappy bird tutorial dont hate me is my first and i cant make random.range

mellow sigil
#

You'll have to tell what the error message is

young abyss
simple egret
#

Your parentheses are misplaced

young abyss
#

Range creates a single number between lowest point and highest point

#

no 3rd argument

last palm
#

oh

young abyss
#

maybe u wanted that 0 outside of those parantheses

simple egret
#

You are missing a comma , and a parenthesis ) as the errors say

#

You're not closing the new Vector3( here

naive swallow
# last palm

Maybe don't do it all in one line if it's gonna be difficult to keep the parenthesis straight

#

Your code doesn't get any faster if it's one line versus multiple. Primitives and Structs cost the same amount of memory whether they're given a variable or not

fossil obsidian
#

guys, I came back with trying to make that puzzle where you clean your PC by removing the coffee you've spilled on it, so I started with the mouse position recognition, but it doesnt work at all, check out my script:


public class CoffeePuzzle : MonoBehaviour
{
    public Camera cam;
    void Update()
    {
        RaycastHit hit;
        Ray ray = cam.ScreenPointToRay(Input.mousePosition);

        if(Physics.Raycast(ray, out hit)) {
            Debug.Log("Acertou: " + hit.transform.name);
        }
    }
}```
somber nacelle
#

is there a 3d collider that is in the direction of this ray?

fossil obsidian
#

it's 2d

#

the only colliders I have in the scene for now is the player and the object I want to recognize

somber nacelle
#

well no wonder Physics.Raycast isn't working then

fossil obsidian
#

oh so what I use then?

somber nacelle
#

take a look at the documentation and maybe you'll see what you should be using for 2d

#

but also you don't need a ray at all, an overlap point would be sufficient

fossil obsidian
#

when I searched to make this script there was nothing saying: "This doesnt work for 2d, use x instead"

somber nacelle
#

that's kind of a silly thing to expect to see

#

!code

tawny elkBOT
ivory swan
ivory swan
robust dome
#

seems to be fine

fleet gorge
leaden cipher
#

(I have already asked this is #๐Ÿ“ฒโ”ƒui-ux but I am unsure if the way to do this is code-related or not, so I am sending it here as well.)

Hey so, Im working on a TD game. I want to have a small UI element like this as a buy/upgrade menu, and I want to ensure that it does not go off-screen.

How can I ensure that the menu appears above a tile when a bottom tile is selected and vica versa, like this example?

(Example from Mini TD 2)

ocean hollow
#

Vector3 thisVelocity = rb.linearVelocity;

why does this throw a null ref error? what am i not seeing?

somber nacelle
#

rb is null

ocean hollow
#

if that was the case then my get component would be the one throwing the error, not this

rigid island
#

nope

somber nacelle
#

that is incorrect, GetComponent does not throw if the component does not exist on the object, it just returns null

ocean hollow
#

oh whoops

last palm
#

how make this

ocean hollow
#

or backwards. i cant remember which is which

last palm
somber nacelle
# last palm

this is called a pipe character or vertical bar, it's location on your keyboard entirely depends on your keyboard's layout

vestal arch
shadow wagon
#

does the pipe character always share the same key as the backslash? thats where its located on mine

#

i feel like ive come across keyboards where it isnt

wind sequoia
#

how can i make the camera look at the mouse position in 3D? ive been using this code that i found as a temporary solution but its clunky and it doesent really follow the mouse position also its a very bad use of the lerp function but for some reason it only works this way,dont ask
rotation.x += Input.GetAxis("Mouse X") * 10; rotation.y += Input.GetAxis("Mouse Y") * 10; var QuatPosX = Quaternion.AngleAxis(rotation.x, Vector3.up); var QuatPosY = Quaternion.AngleAxis(rotation.y, Vector3.left); transform.rotation = Quaternion.Lerp(QuatPosX * QuatPosY, transform.rotation, Time.deltaTime * 60);

#

i tried using something like
camera.main.screentoworldpoint(input.mouseposition)
but for some reason that doesent update at all,the position seems to remain at the world origin and moving the mouse doesent change the coordinates of that

vestal arch
last palm
#

ehm ehm help?

swift falcon
#
using UnityEditor;

[CustomEditor(typeof(PlayerController))]
public class PlayerControllerEditor : Editor
{
    SerializedProperty gravityStrength;
    PlayerController playerController;

    private void OnEnable()
    {
        gravityStrength = serializedObject.FindProperty("gravityStrength");
        playerController = (PlayerController)target;
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        DrawDefaultInspector();
        if (playerController.enableGravity)
        {
            EditorGUILayout.PropertyField(gravityStrength);
        }
        serializedObject.ApplyModifiedProperties();
    }
}

Is there a way to remove fields after they have been drawn?

This adds a second field if the boolean enableGravity is checked, but now I have either one or two gravityStrengths. How do I remove the one drawn by DrawDefaultInspector?

vestal arch
last palm
vestal arch
#

well, that's a different thing

somber nacelle
# last palm

you need to configure your !IDE if it isn't showing errors in the code๐Ÿ‘‡

tawny elkBOT
vestal arch
#

also, what's with that Obsolete annotation?

last palm
vestal arch
#

so did you read the warning message?

#

i mean, GameManager should probably be a singleton anyways, rather than you Finding it every time you need to access it

somber nacelle
# last palm

log the value of spriteIndex and the length of the sprites array

last palm
#

i fix it

ebon burrow
#

If i wanted to create a large open world sandbox type game, how would i organise and structure my scenes?

zinc tartan
#

Im using a character controller for controlling my games player and i have a seperate script that moves the object as if it were parented to another object which can be anything, the problem is the script works fine when i try to use it with a simple object like a cube or sphere but when i try to use it with the player whether it has a rigidbody or a character controller it just doesnt work properly and seems like it doesnt move as much as it should and ends up lagging behind the object its "parented" to here is my script for it

using System;
using UnityEngine;

public class FollowParent : MonoBehaviour
{
    [SerializeField]private GameObject _parent = null;
    private GameObject _lastParent;
    private Vector3 _offset;
    private Vector3 _lastChildPosition;

    private void Start()
    {
        if (_parent != null)
        {
            _offset = transform.position - _parent.transform.position;
            _lastChildPosition = transform.position;
        }
    }

    private void Update()
    {
        if (_parent != _lastParent && _parent != null)
        {
            _offset = transform.position - _parent.transform.position;
        }
        if (_parent != null)
        {
            if (transform.position != _lastChildPosition)
            {
                _offset = transform.position - _parent.transform.position;
            }
            else
            {
                transform.position = _parent.transform.position + _offset;
            }

            _lastChildPosition = transform.position;
        }
        _lastParent = _parent;
    }

    private void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("Ladder") && Input.GetKeyDown(KeyCode.F))
        {
            _parent = other.gameObject;
            print(_parent);
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Ladder"))
        {
            _parent = null;
        }
    }
}
somber nacelle
#

when making one object follow another you typically want to update the following object later than the object it is following, one way to ensure that happens is to update the following object in LateUpdate rather than Update

zinc tartan
#

it still doesnt work even i put it in late update i just had it in update to test if that was the issue for whatever reason

#

whats weird is if i disable the character controller it stops it from lagging behind

placid ridge
#

Hi, can I get a sanity check? Is BlobHashMap in Unity.Collections? I'm using 2.5.3, if that helps

swift falcon
#

@placid ridge What is the issue?

cosmic rain
zinc tartan
cosmic rain
#

If the offset were to change every frame the following object would start lagging behind.

zinc tartan
#

i want it to constantly update, it works fine if i have it on an object without a character controller

cosmic rain
#

Add logs and see for yourself.

placid ridge
# swift falcon <@708676637683744809> What is the issue?

I'm trying to do some vibe coding and the Gemini LLM is insisting that BlobHashMap exists. I don't think it exists in the official Collections package, so I'm probably going to switch over to a list since the performance impact isn't large, but at this point, I just want to know if BlobHashMap really doesn't exist in the official Collections package ๐Ÿ™‚ Thanks, by the way

cosmic rain
placid ridge
#

I did, but I'm new to Unity (but not coding) and am still learning the ecosystem. And sometimes docs don't have a perfect coverage of what's in a package. Rare for larger projects, but it does happen!

zinc tartan
# cosmic rain Add logs and see for yourself.

added logs, it updates only when the parent changes and when the object moves not sure what you mean by its not updating when i want it to, if you have a better explanation it would be great

cosmic rain
placid ridge
#

Hahaha that's a good point

zinc tartan
cosmic rain
#

Shouldn't it follow the parent with the same offset to keep up?

zinc tartan
zinc tartan
cosmic rain
zinc tartan
cosmic rain
zinc tartan
#

it does what i said in my last message

cosmic rain
#

So it stops lagging behind?

zinc tartan
#

yep

cosmic rain
# zinc tartan yep

Great, so now you know that setting an offset there is the cause of the issue. Now to understand why that happens.
So back to logging. It must be setting the offset when you don't want it to be set(i.e. when the object is not moved by anything and just follows).

astral sky
placid ridge
#

Yeah, that's what I'm finding. It's fun to code with LLMs, but they do have their limitations.

zinc tartan
# cosmic rain I really don't understand why we need to do this debugging 101 session here. Thi...

because im pretty sure this doesnt have to do with what youre telling me and something deeper with how the character controller works because it works flawlessly on objects without a character controller and could also be something to do with netcode for game objects though i really dont think thats the issue and this honestly hasnt cleared anything up ๐Ÿ˜… thank you for the insight though

lean sail
placid ridge
#

I mean, usually yeah, but I've been coding for over 20 years with tons of experience in larger scale groups. Coding with an LLM is no worse than coding with an intern who makes a lot of mistakes, but can give you insights into how systems work. As long as you structure your code to fail fast, it's not an issue. I've been coding with LLMs for a bit now. They can really speed up your work, but you have to stay aware of how they like to fail and what it looks like. But I must admit, coding for newer stuff with an LLM is certainly much more risky than it'd be if I were dealing with an older system.

#

Plus they can introduce you to new, more efficient practices at times.

chilly surge
#

The amount of time you wasted just now on verifying its hallucination probably already offsets whatever it saved you.

placid ridge
#

Not really, no

#

If you're working in stuff which is adjacent to your knowledge, they offer huge speed boosts

#

Plus the overall quality of simple code is usually the same as your own code, or sometimes higher

#

I'd highly recommend LLMs for simple code.

#

For more complex and adjacent stuff, they are excellent tutors at a minimum.

chilly surge
#

Using LLMs to write code is like babysitting a junior that never improves no matter how long you mentor them. But well if it works for you then go for it then.

lean sail
placid ridge
#

But code is usually the same across most systems. Modern IDEs do a good job for telling you if you're about to go off a cliff

#

I mean across majorly different systems

#

Network code, cloud infrastructure, etc. There's a huge amount of overlap

#

If you have enough knowledge from enough systems, you can start to spot sus code when it happens

#

And for that, that's what testing is for

chilly surge
#

Not all problems can be caught by IDEs, case in point the nonexistent API you were asking just now, because IDE cannot possibly know all the packages Unity has.

placid ridge
#

The thing, it takes half a second to see a red squiggle and investigate. From there, it's a simple substitute for what's causing the problem. It took the LLM 5 seconds to spit out the whole code segment. It took me a minute to read everything, verify it looks somewhat right, then check it. Sure enough, there was a simple error which can be caught. The logic was sound. If I had to write that by hand, it would have taken me 10-15 minutes, but because this is adjacent knowledge, I would then have to spend another few minutes searching for the exact types I can use and whatnot. I can understand the pushback against using LLMs, but not using them in 2025 risks putting people behind the wave, yknow?

cosmic rain
cosmic rain
#

I think llms are great assistants, but one when you know how to do it yourself

#

Otherwise it's the same as copying code blindly from the internet

placid ridge
#

I agree with those points, but as a heads up, I'm not advocating for beginners to use LLMs.

#

But for experienced coders? Yeah, they're good if you know what you're doing

lean sail
# placid ridge The thing, it takes half a second to see a red squiggle and investigate. From th...

Just saying, most experienced devs here are going to suggest against using it for the general public, even though they may use in some aspects. You aren't gonna convince anyone here that you should be using it. The conversations became so frequent there is a dedicated forum for it https://discord.com/channels/489222168727519232/1352599815770341479
Still, the suggestion for you is not to use it. You are a beginner currently in unity!

#

and you really aren't helping your point considering your issue was if the code even exists.

placid ridge
#

Thanks for the heads up. If I feel like continuing the convo, I'll hit up the forum. ๐Ÿ™‚ I'll drop the topic now.

mossy flare
#

I have heard that lerping towards values with the variable as A is bad

#

Because it never reaches the final value or something (even though it actually does)

#

What is the alternative, though? The most common solution I see is to ground the time at some point from when the lerp starts, so you're doing timeElapsed / startTime

#

How would this be applied to multidirectional movement? You don't exactly have a point of reference to go off, especially not since the player can be pressing any combination of WASD and you can't just keep resetting the time

cosmic rain
lean sail
# mossy flare I have heard that lerping towards values with the variable as A is bad

This doesnt really make sense. A just represents the first variable, the start position.
A common mistake is doing transform.position = Vector3.Lerp(transform.position,...,...)
Because this is no longer the start position, it's the current position. The T variable is a normalized value between 0 and 1 which is essentially a percent of how far it should be from start to end

mossy flare
cosmic rain
mossy flare
#

Lerp has (A, B, T) as parameters, sorry

mossy flare
lean sail
#

Time.deltaTime also doesnt make sense there but I described why above in the same message

lean sail
#

You are using the current speed, not start. Your T parameter doesnt make sense here either

cosmic rain
#

Ok,but that still doesn't explain anything. Do you perhaps mean that the third parameter(time) is not moving between 0 and 1?

mossy flare
lean sail
#

if you want it to go smoothly from A to B over a set time, you store what the start is and have T go from 0 to 1

currentTime += Time.deltaTime;
normalizedTime = currentTime / totalDuration;
speed = Mathf.Lerp(startSpeed, newSpeed, normalizedTime);
chilly surge
#

Sadly Mathf doesn't have the equivalent of math.remap from Mathematics package.

mossy flare
chilly surge
#

Sure, but it would be nice if we didn't need to write one.

#

(Not that I think an extension menthod on float is a good idea either)

mossy flare
chilly surge
#

Hmm, I supposed "not a good idea" is not the right wording, but foo.DoSomething() has the semantic that it's foo that's doing that something. someFloat.Remap(...) doesn't make much sense, that float isn't doing the remapping, it's being remapped.

mossy flare
#

Hm, maybe we just see it differently

#

Like, for example, myfloat.SubtractTen() would clearly subtract 10 from the float, this is intuitive to me

#

More practically, mesh.FixErrors() would also perform stuff on itself

#

Even in Unity functions, myVector.Abs() gives you the same vector but in absolute. Nothing unusual about this

chilly surge
#

mesh.FixErrors() makes sense that it would fix its own errors by mutating mesh itself, so after the call mesh has now changed to be error free

#

Do you expect someFloat.SubtractTen() to change someFloat after the call?

mossy flare
#

No, just return the modified float

mossy flare
#

Hello cat

chilly surge
mossy flare
#

And in what way is this different? vector.Abs() gives you an absolute vector, myF.Remap(whatevs) gives you that

mossy flare
chilly surge
mossy flare
#

Well, at least my remap function would be consistent within the Unity API ๐Ÿ˜†

#

Something about writing Extentions.Remap(float, this, that, this, that) is so ugly compared to myfloat.Remap(this, that, this, that)

night harness
#

unless im wrong

mossy flare
lean sail
night harness
mossy flare
night harness
#

real ๐Ÿ˜›

mossy flare
lean sail
#

This feels like a separate problem from asking about how lerp works

chilly surge
#

Yeah that's kind of the issue of that API design, some calls like texture.Apply() modifies itself, whereas some calls like vec.Abs() doesn't (and instead returns a new copy with the modification)

night harness
#

this is a really fucking dumb analogy but Toast(bread) just makes so much more sense than bread.Toast() imo

#

because your doing something to the object

#

the bread isn't toasting itself (except for that one hit indie game)

chilly surge
#

Yeah it all goes back to the semantic difference of "it's foo that's doing the something" not "something is being done to foo"

mossy flare
lean sail
mossy flare
#

uhuh

#

how do I achieve this same effect using lerp the "proper" way?

lean sail
#

But it sounds like you might wanna use MoveTowards

worldly hull
#

im planning for my farming game

lets say the farming game will have 6 big pieces of land with maximum size of 10X20, thats 1200 tiles
if i make a gameobject for each of these grids, it will hurt my phone damn bad right?

#

so someone has suggested me instead of really making an exact object and drop it into the farmland, maybe i can change the mesh with approximate objects instead

#

how?

i did have an idea in my mind tho

maybe calculate the ratio of object in each farmland , based on this
get the ID, maybe?

public class Farm{
    [field:serializedField] public int height {get;private set;}
    [field:serializedField] public int width {get;private set;}
    Farm_subsection[,] theMap = new Farm_subsection[height,width];
}

//model class (object)
public class Farm_subsection{
     public Crop crop;
     public int timer; //active havest timer, in seconds
}

public class Crop{
     public int ID;
     public string name;
     public int price;
     public int havestTime; // time needed, 4hrs? 8hrs?
}```

to determine the ratio of spawned meshes(the crops)
#

for visualization, i would ready for 10-20 sections , only to show crop is there maybe

#

like if a farmland got 100grid
30 red flowers -> 3 section will show red flowers
20 blue flowers -> 2 sections...
50 green flowers -> 5 sections...

#

they will still be spawned by gameobject

#

but that would be less costy than having 200 objects right

#

any better idea?

cosmic rain
#

Is it 2d or 3d?

worldly hull
#

3D

#

and i would make the game with medium-high tier graphic quality in URP

cosmic rain
#

Is each tile type just a different texture?

worldly hull
#

all tile will share the same texture, characteristics
even u can change the skin of the farm, the tiles inside it will be consistent

#

wait , were talking bout the visualization tiles right?

cosmic rain
#

Sort of. Isn't that what you're worried about?

worldly hull
#

yes

cosmic rain
#

Anyways, I'd start from using the simplest approach to get it working at least.

#

Then test and profile on your target device. Perhaps you don't even need to optimize anything.

worldly hull
#

ok thx๐Ÿ‘

slim sphinx
#

Hey,
Im sorry if i interupt you two.
I got an small question: Im trying to make an Room based generation (in 3D) for an small driving game im working on, i want it to be one clear path the player can follow so he reaches the goal at the end, the Problem is, i have no clue how i can avoid loops and collisions without making multiple paths and i also want the path to get a little complicated so he need to do multiple turns and not just move forward, does anyone got an idea how i could achive it.
I can sent my current code if needed but the code is really buggy, like i said its spawning sometimes "rooms/streets" in eachother

cosmic rain
#

If you need help with the former, you should provide more info on the issue(screenshots or videos could help) and the relevant code.
For the latter, you'll need to explain better what you're trying to do and maybe provide examples from existing games/tutorials.

slim sphinx
#

Sorry, I wrote it really unclearly:
So my problem is that I don't really have a clue how to do it in general: I would like to have a system that builds a road based on prefabs, this road should have a clear path without direct branches, so that the player gets from the start to the finish without problems, but the road should also be nicely winding so that he often has to turn off and overall has it a little more difficult. My problem is that I can't think of a way to prevent my road from spawning into each other.

wet prairie
#

hey ive been struggling for like a day now on this error and i dont really get how to fix it, this happened after i tried to build an android project , the only thing in the scene is the google xr plugin import

#

i have followed their startup guide and it just keeps popping up no matter what i do

cosmic rain
#

Roads in racing games are often hand designed.
You might be able to implement a procedural algorithm, but it might not be as good as designing by hand. And there might be corner cases that cause issues.

If you really want to go with procedural generation, I can think of several approaches:

  • Implement an algorithm that generates the road path. This might be quite complicated. Might want to look up some tutorials or articles on that.
  • build the city or some other environment with realistic roads first, and then just trace a path randomly through the environment(on existing roads).
prisma yew
#

if the city is in a grid you could look at a wave function collapse algorithm but I am unsure how effective that would be

cosmic rain
worldly hull
#

i mean complicated racetracks doesnt mean it must be 2D and spreaded like game map

cosmic rain
tawny elkBOT
worldly hull
#

u can use 3D concepts to build 3D racetracks

#

with heights

slim sphinx
#

Ye but i need it to get generated somehow

worldly hull
#

that would be very hard to achieve tho, because u need to think of height/depth now

wet prairie
stable osprey
#

start with building empty project, then work on it, see what breaks it

wet prairie
stable osprey
#

well google XR is what breaks it then

wet prairie
stable osprey
#

have you tried doing what dilch said and removing the unknown parts from your manifest?

wet prairie
stable osprey
wet prairie
#

ah my bad then i thought this is like the general chat here

zinc tartan
dense estuary
#

Is there a way I can blend between two Cinemachine NoiseProfiles? Or change the settings of the noise profile at runtime?

#

I want to add camerashake, but my previous attempt led to large cuts between camera rotations due to zero blending.

shadow wagon
wet prairie
#

like it has 0 objects all default settings

crimson trellis
#

Hi I'm using unity version 2023 and I'm quite near a project deadline, how can I get the old navmesh ?

cosmic rain
still lagoon
#

hey guys im trying to create some unit tests for a uni project, and its important that i dont break encapsulation but i still should test certain methods. the solution i tried was instead of making them private, stuff that needs to be tested should be internal so it can be accessed by the unit test, however i cant seem to get it to work?

#

*im using the NUnit framework if that's important

#

I know that it would be far simpler to just make a public method that returns that value, but I feel that I'll end up flooding my class with useless methods where there might be a better cleaner solution

quartz folio
still lagoon
#

thank you

#

also, is there any downside to doing this? it feels a bit weird changing access modifiers just to test

#

but idk what real-world issues that could cause

quartz folio
#

It only affects your testing assembly/assemblies of the same name, so no, other than doing what it says on the tin I don't see what issue you could have

still lagoon
#

so its basically still private as far as anything outside that assembly is concerned?

quartz folio
#

Of course

still lagoon
#

thank you

chilly surge
#

Personally, I would consider testing only public API surfaces. If WordA is normally unsettable by consuming code, then tests setting it is not really representative of how it's going to be set.

quartz folio
#

That would be proper, but if there's value in bypassing it, at the end of the day that simplicity can save time and effort

chilly surge
#

At the cost of long term maintainability though.

golden breach
#

are there any downsides to using dictionaries instead of 2d arrays for holding 2d world data? for example, in my survival game, I have a Dictionary<Vector2Int, Block> for my block array, which makes it so that it doesn't have a set size and blocks can be placed at any location. are there any downsides, particularly performance wise with this method?

vestal arch
kind nymph
#

having an issue with getting an object to look towards a transform point. It works for the right side but when the point moves over to the left it looks in the complete opposite direction and I have absolutely no clue as to why. (game is 2d btw, thats why im resetting the x and y to 0)

    public void LookTowards(Transform point)
    {
        // if (IsFacingObject(point)) return;
        Vector3 dir = point.position - transform.position;
        Quaternion rot = Quaternion.LookRotation(dir, Vector3.up);
        Quaternion finalRot = Quaternion.Lerp(transform.rotation, rot, turnSpeed * Time.deltaTime);
        finalRot.x = 0;
        finalRot.y = 0;

        transform.rotation = finalRot;
    }
still lagoon
#

why does this default to a TMP font material?

#

"CreateLetterBlockTest (0.161s)

Unhandled log message: '[Error] Material 'LiberationSans SDF Material (Instance)' with Shader 'TextMeshPro/Mobile/Distance Field' doesn't have a color property '_Color''. Use UnityEngine.TestTools.LogAssert.Expect

UnityEngine.Material:get_color ()
BlockFactoryTests/<CreateLetterBlockTest>d__4:MoveNext () (at Assets/Tests/Runtime/BlockFactoryTests.cs:54)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

Shader does not have a _Color or _TintColor property.
Material 'LiberationSans SDF Material (Instance)' with Shader 'TextMeshPro/Mobile/Distance Field' doesn't have a color property '_Color'"

#

I'm 100% sure it's that line too because commenting it out fixes it

#

!code

tawny elkBOT
still lagoon
jagged moss
#

hi guys I was trying to do a game about like ship, which is always going forward and you rotate it with A and D. But I dont understand how, I have written a code but it works really strange. Can someone help?

using UnityEngine;

public class ShipController2D : MonoBehaviour
{
    public float speed = 5f; 
    public float rotationSpeed = 100f;

    void Update()
    {
        if (Input.GetKey(KeyCode.A))
        {
            transform.Rotate(Vector3.forward * rotationSpeed * Time.deltaTime);
        }
        else if (Input.GetKey(KeyCode.D))
        {
            transform.Rotate(-Vector3.forward * rotationSpeed * Time.deltaTime);
        }

        transform.Translate(Vector2.up * speed * Time.deltaTime);
    }
}

vestal arch
jagged moss
#

hmm let me try it

#

Oh I forgot to say, its 2D game

#

with Vector3.up it rotates in 3D

vestal arch
#

i shouldve noticed the 2D, mb

#

could you elaborate on how exactly it's behaving strange?

jagged moss
patent perch
#

Do u know how I can unsubscribed a void from an Action only if its subscribed?

vestal arch
#

no such thing as "a void" here, that's a method

patent perch
#

yes sry

violet nymph
#

What are you using to subscribe to it?

#

Unity events?

patent perch
#

Action

vestal arch
#

can you not just.. unsubscribe unconditionally?

patent perch
#

yes but it would say that my method isnt subscribed, create an error

violet nymph
#

Why would you be unsubscribing if it isn't considered to be subscribed? I'm pretty sure we will need some more info

#

Maybe send the code you have?

patent perch
#
    {
        if (RoomsManager.Instance)
        {
            RoomsManager.Instance.OnNewRoom += OnNewRoom;
        }
        else
        {
            RoomsManager.Instance.OnNewRoom -= OnNewRoom;
        }
    }

This function is called with this SceneManager.sceneLoaded
I want to subscribe to my RoomsManager when this Instance exists

#

But unsubsribe it when there no more RoomsManager

violet nymph
#

Use a code block

#

!code

tawny elkBOT
violet nymph
#

Inline code one

#

It makes it easier

vestal arch
#

i think this is an x/y problem
step back and consider your design

jagged moss
violet nymph
violet nymph
vestal arch
# jagged moss

ok so what's the issue here exactly?
is this the result from holding down w+a?

still lagoon
#

nah guys i wrote a unit test thats gaslighting me

vestal arch
#

that seems.. correct

still lagoon
#

the color is blue not red but its passing

violet nymph
#

You set the color to red

vestal arch
violet nymph
#

Although it says blue

#

Which may be why

#

It might think it's red because you set it to red

still lagoon
#

ok apparently its red but where is the debug that shows it got changed to red

violet nymph
#

There is none, it was always red

still lagoon
violet nymph
#

Color color = Color.Red

still lagoon
#

whenever the color changes its done via the decorator

#

which means it should always be logged

violet nymph
#

But it didn't change?

vestal arch
#

the color variable is red
unless you directly change it, or pass it by ref somewhere, it's not gonna change

still lagoon
#

i know, that stays the same

vestal arch
#

Color is a struct, it's passed by value unless specified otherwise

still lagoon
#

its the particle system material thats meant to change color

#

and its logging its blue for some reason

vestal arch
#

add more logs to see when that's happening

#

for all we know it could be way after the test

still lagoon
#

it cant be because im tearing it down as well

#

!code

tawny elkBOT
still lagoon
#

its a bit of a mess because ive been at it for a while, excuse that

sturdy holly
#

is there a way to find out what render pipeline a compiled/sold unity game uses? steamdb sometimes lists but if not? any file I can look out for etc

sturdy holly
violet nymph
#

It's saying from the decorator

still lagoon
#

the debug itself is from the decorator

violet nymph
#

The material changed to blue, you are checking if red is red

still lagoon
#

but that's the only thing that should be changing it

#

so idk how it can end up red and pass the test

#

i also have no idea why it would be getting set to blue either

violet nymph
#

Well where the arrows are:
Color color = Color.red;

Assert.AreEqual(color, new Color(1, 0, 0, 1)); (Is red equal to red)

#

That's that part

#

Setting to blue may be a different script

#

The code provided sets the particle color to white

still lagoon
#

right, but its passing the test after that as well which checks the material

#

exactly, so how is it ending up red

#

i want it to, dont get me wrong

#

but it shouldnt be rn

#

not if the decorator is saying it changed to blue

violet nymph
#

I'm not 100% sure about how this type of debugging works so I don't really know persay what I'm doing

still lagoon
#

wait i figured it out

#

it still doesnt make 100% of sense to me but i think the debug is somehow from another test

violet nymph
#

Could be

still lagoon
#

here is where the blue would come from

violet nymph
#

Yeah, that would be setting whatever materialB is to color blue

still lagoon
#

yup

#

but that introduces even more questions

#

like where is the decorator debug from the other test

#

and if its not running how is it turning red

#

ok

#

turns out

#

that im very stupid

#

and have been looking at the wrong test the entire time

violet nymph
#

Happens to all of us at some point

still lagoon
#

ok thankfully it means that it actually is passing the test

violet nymph
#

Yeah

still lagoon
#

and no weird voodoo black magic is happening like i thought earlier lol

#

thanks for the help though!

violet nymph
#

No problem

rigid island
north cypress
#

my appoligies

#

moving across

still lagoon
#

like is there a guide/rule of some sort that helps you tell them apart or?

rigid island
still lagoon
#

i didnt see what he posted, just wondering because ive been confused between the 3 channels for a while now

rigid island
#

a general question might be.. I am working on this A* pathfinding but the path is a bit to "jagged" How would I smooth out the points so agent moves curved interoplation instead of jagged

still lagoon
#

ah okay, so its just assumed knowledge mostly

rigid island
#

basically

still lagoon
#

thanks for the clear up

mossy flare
#

I have a question about lerping. So using something like movement = Vector3.Lerp(movement, targetVel, Time.deltaTime * acceleration); is bad, right. I've seen people saying that you should ground t at a certain point in time like

currentTime += Time.deltaTime;
movement = Vector3.Lerp(movement, targetVel, currentTime / totalDuration);
#

I really don't understand how to apply this to omnidirectional movement though. When am I supposed to reset currentTime?

rigid island
mossy flare
rigid island
#

like the coroutine solution you could potentially reset after the while loop

mossy flare
#

And when does the while loop end?

rigid island
#

when the target value was reached

somber nacelle
#

Use MoveTowards which actually uses the parameters you've passed in the way you expect

rigid island
#

yea MoveTowards would be easier to use

mossy flare
#

bruh what do you mean try it and see, the problem of when to reset currentTime still remains the same

#

You would need a point of reference from which to start the easing function

somber nacelle
#

MoveTowards takes the current position, the target position, and the speed at which you'd like it to move. time is not a factor here

vestal arch
somber nacelle
#

this is a replacement for movement = Vector3.Lerp(movement, targetVel, Time.deltaTime * acceleration); where they are passing speed as the last parameter.

mossy flare
vestal arch
#

oh, i misread targetVel as targetVal and didn't read anything else as velocities, mb

somber nacelle
mossy flare
#

right

#

thanks

old elk
#

@astral sky i guess this is probably a safe place to discuss implementing general stuff lmao

astral sky
#

Sure

old elk
#

but re: the VPK thing, it's sorta what I'm doing? i took "inspiration" from modding rimworld, which is as easy as overriding XML paths in the mod

#

no editor required

#

when I say inspiration I mean "actually this works great, I might as well roll my own version"

astral sky
#

Is rimworld slightly like starbound (?) where quite literally everything is defined through a xml?

old elk
#

yeah

#

almost every bit of content in rimworld is done via xml

astral sky
#

That's crazy then

old elk
#

like all the items, buildings, etc. are done through XML

astral sky
#

The easier your own development pipeline is to develop and add new content the easier it is for third parties to mod it as well

old elk
#

I'm being a bit more aggressive about how freely people can modify things

old elk
#

I actually wrote a custom event dispatcher as well (i hate hate HATE C#'s event system and Unity events are too slow, plus I try to detach from Unity's APIs as much as I can)

#

then I realized I don't really have a ton of use for that event dispatcher in the actual game itself, but hey, at least mods can hook into it

#

(as an alternative to harmony patching)

astral sky
#

I don't remember anything of harmony at all, I know it's used heavily in some unity games but it really depends on communities

old elk
#

harmony's the go-to patcher for rimworld modding, though i think prepatcher is faster

#

but harmony is a lot easier to use idk

#

it's also used in Elin but Elin is an extremely strange and niche game

#

(elin is also a great example of how not to write code. or do content authoring.)

astral sky
#

I've never played Elin nor Elin+ so I can't say

old elk
#

oh are you thinking of Elona

#

same guy, diff game though

astral sky
#

oh

#

Yeah lol I thought you were talking about the OLD game

#

Not the new one

old elk
#

tl;dr he does the content for Elin through some kind of weird compiled Excel spreadsheet

#

it actually hurts my brain

#

don't do that to your modders LMAO

astral sky
#

I've seen plenty of japanese games that do that

#

Actually I think its explicitly only japanese games i've seen do that for some reason

old elk
#

i think what's weirder is that No Man's Sky has all these archive files that it uses, and then inside the archive files is just

XML

#

maybe there's more to it but i vaguely remember that from a few years back

rigid island
#

because they provide easy structure

old elk
#

it's the archive files that i'm confused about

#

why go through the extra steps lol

#

actually

#

I suppose it'd make sense for load times if you did something like parse all your content defs into memory, then just write those bytes out to a file that can be loaded into memory far more quickly later

rigid island
#

why does unity use YAML ? same thing. Provided easy serialization structure / access

old elk
#

you're misunderstanding what i'm saying

astral sky
old elk
#

or wait

#

are you talking about the excel spreadsheet lol

#

Excel spreadsheets are compact and readable enough, I think they're much more readable than XML/JSON (which are vertical)

rigid island
old elk
#

okay yeah my bad - I thought you were talking about the XML archive thing at first

rigid island
#

granted excel is weird as hell but I've seen it lol

old elk
#

The shitty thing about MS Office files is that they're effectively .zip files, like you can open a .docx file with WinRAR if you want

#

but that makes parsing them as text really annoying to do

astral sky
#

Personally I don't know whenever to serialize my data with JSON or XML or something else, something user readable and small and fast is what I'm looking for

old elk
#

yeah idk I don't think there's anything fundamentally wrong with using a CSV format for content, especially if it's something repetitive as hell

#

JSON is faster, in general, i don't find it very readable though

astral sky
#

Wasn't JSON developed after XML and kinda has taken over XML in a lot of dev?

rigid island
astral sky
#

At least stuff like web...

old elk
#

i prefer XML for readability and clarity of what element you're currently in

#

JSON is generally what's used for stuff like responding to GET requests

#

It's also used for fast serialization/deserialization for things that you generally won't edit as a player or developer/modder, though ofc people use it for editable stuff as well

rigid island
#

XML has limitations on types too iirc , doesnt support arrays structures ?

old elk
#

imo XML > JSON if you intend to edit it strictly through a text editor, at the expense of speed

though for something like a content system, you could maybe hash your game .exe and .XML files on load and store that hash, then precompute all the content you're loading from XML, write the contents of the memory you're using for that to a file, and only re-parse everything if the hash from earlier has changed

#

which would eliminate re-parsing all your content every time the game loads lol

old elk
#

I wrote my own though lmao

#

It's still fine for reading the files into an XmlDocument, but after that I just handle everything myself

night harness
#

did i miss the harmony talk ๐Ÿ˜„

old elk
#

slightly :p

#

feel free to contribute to it though lmao

rigid island
#

I have nightmares from XAML to enjoy XML lol

astral sky
old elk
#

currently having a code design crisis in terms of

"okay, I've fired this ConstructionCompleteEvent, and I know I need to recompute navmeshes for this chunk, but do I do that by handling the event, or do I do that by adding the code right after I dispatch that event instead?"

night harness
# old elk feel free to contribute to it though lmao

i got a fairly popular modding api using harmony and it was genuinely surprising how little hard limitations there were when you mix assembly injection with assetbundles and/or addressables

I feel like in general best way to support longterm content addition and/or trying to make things not too dreadful for modding is just general code composure thats more event and iterating through collection based to easily allow new stuff to slip in

night harness
old elk
#

but I suppose when I put it that way I should just hardcode in the navmesh change after the event dispatch lmao

#

"kenshi wall syndrome" being the ubiquitous issue of building walls in games, where if you build them on a slope, they basically end up stair-stepped because each wall is positioned according to where the center of it ends up on the slope lmao

which means you have little triangles of open space under the wall instead

night harness
#

this response is possibly bad for optimization perhaps but i feel like what you do in house shouldn't rely on telling people about it

in my head i would do

construction complete
rebake navmeshes (because it needs to happen in response to construction complete)
tell people it happened (in a "complete" state where the event isn't half finished and for example modders could know the navmesh is updated)
let them update the navmesh if they need to

night harness
#

like at least from reading it the like programming/logic """task"""" of completing construction includes the bake in my head

astral sky
#

Working with DOTS just gives me a lot of worries about asset creation / usage and modding, I guess it'd use a lot of factories and APIs like old games

old elk
#

i'm gonna be real with you, my content loader just abuses the ever-loving fuck out of reflection

astral sky
#

isn't reflection bad because Unity just keeps it in memory forever?

night harness
old elk
#

no?

#

reflection is "bad" when it's used in runtime methods, because reflection is slow

astral sky
#

You mean reflection for codegen or something?

old elk
#

no

#

no code gen here

#

i mean like fetching method info from a C# Type

night harness
#

At least in the communities i've been in there's a fairly small amount of experienced programmers, I barely know any that have experience in modding and DOTs (they do exist im sure but gets pretty rare)

old elk
#

i'm not sure what you mean when you say working with DOTS I guess

#

that feels like a super broad term

#

unless it means something specific here and I missed the memo

night harness
#

In terms of an outside modder trying to manipulate and extend a unity game built using a lot of DOTs

old elk
#

can I get like a concrete example

#

wait

#

like a scriptableobject? lmao

#

honestly if you want to make your game as moddable as possible you're better off treating Unity as a renderer (and level design tool if necessary)

astral sky
night harness
#

no as in like ecs/burst/job shit

old elk
old elk
#

burst/jobs are a different beast

night harness
#

I don't personally know any modder who is familiar with ECS, You'd be suprised

#

I myself have no experience with it

astral sky
low hinge
#

Same, we also don't support modding here afaik

#

Unless you're talking about making a moddable game

old elk
low hinge
#

DOTS is an ECS

night harness
old elk
#

or is there just a completely different set of acronyms here

old elk
night harness
old elk
#

p sure the others are too

rigid island
#

Dots includes ecs, jobs etc

#

just data oriented workflow

night harness
#

My experience is from modding other peoples games but ๐Ÿค

old elk
#

i worked in AAA game dev instead, which was objectively messier

#

and more complicated

night harness
#

I think respectfully you might have an overexaggeration of the programmers who get involved in some games modding communities ๐Ÿ˜›

old elk
#

actually fair

#

when i was like 18 i tutored this guy a couple years younger than me in Java and after a bit it turned out he'd just been pasting code snippets from google instead of trying to understand anything I was telling him

#

and one time he sent me a code snippet where he pasted an entire method, declaration and all, into another method and could not figure out why it was causing an error

night harness
#

Only reason my modding stuff has blown up is because it lets people make mods without programming at all lol

old elk
#

I've also seen some genuinely questionable code when decompiling other mods

astral sky
#

A lot of DOTS involve baking and blobs baking, which the point of it is offering fast, precompiled content, so....

low hinge
astral sky
#

You'd have to do that stuff at runtime, unsure how bad that would be

astral sky
low hinge
#

I don't think DOTS is 1.0 though, just parts of it? Or did I miss that

old elk
low hinge
#

A lot of people I know use LeoPotam's ECSLite. Very easy to get into

astral sky
#

DOTS is just.. all of Entities + Entities hybrid + Rendering?

#

Also jobs and burst

night harness
#

so far my only Unity villains as a modder have been

-tags
-layers
-not being able to load a scene, touch its stuff before it gets awake/onenable calls and then unload it
-enums !!!

#

the last one isn't Unity specific but still

old elk
#

i'm trying to work out something for tags/layers myself right now lmao

#

what's up with enums?

night harness
#

not easily extendable

old elk
#

ah

#

back when I made minecraft server mods I got around this by using data classes instead

#

there was a lot of passing strings around with that one

night harness
#

right now i use scriptableobjects in place of enums and physics materials in place of tags

astral sky
#

I really don't know how to make items / buffs / damage types without an enum

old elk
#

but it got to the point where it was all content system driven so it's not as if I ever had to manually go "GetDamageType("physical")" or anything like that

astral sky
#

And how to go around them, I'm no way in hell doing a dictionary with a string lookup, enums are just way better

low hinge
#

Just be sure to never store state in a SO

old elk
#

dictionary with string lookup is completely fine if you're configuring all the damage types yourself anyway

night harness
old elk
astral sky
#

A catalogue or something? I'm trying to get really away from catalogues to not have catalogues because

#

Nobody likes a 30 second long boot up time...

old elk
#

i have no idea what a catalogue is

astral sky
#

Which I am aware is a major issue in some games

old elk
#

my rimworld install takes 20 minutes to load

astral sky
low hinge
#

You CAN have a catalog of them sure, but no need. Instead of a damagetype enum, for example, you just stuff a SO in there

old elk
#

i would not use scriptableobjects if you want people to make mods that don't require creating an editor project

#

unless SOs can easily be edited outside of the editor now

astral sky
#

Maybe deserialize them from jsons?

astral sky
old elk
#

serialization/deserialization are the main answer to this

night harness
old elk
#

oh, last time I used them they were a pain, but that was years ago lmao

night harness
#

i don't think it's that big of a deal

old elk
#

but back then I was using them As Intendedโ„ข๏ธ so it wasn't an issue

low hinge
#

My game uses a lot of scriptable objects instead of enums. I use them for my damage types including damage type mitigation. Works extremely well

old elk
#

not a Unity game but I did something similar for a minecraft mod I made some years back, except it's YAML instead

astral sky
low hinge
old elk
low hinge
#

If you're modding maybe

old elk
# low hinge

I'd maybe refrain from having the description manually created for that if you're not working alone lol

astral sky
#

I can't just use strings in burst, data has to be non-managed

low hinge
#

I'm working alone

#

But I don't see what you mean

astral sky
#

Like, the damage types and buffs have to be either unmanaged data or prebaked blobs

old elk
#

i'm not super familiar with burst tbh, i'm using it for world gen on my end but i don't know the full extent of what it does

low hinge
#

This is designer friendly

old elk
# low hinge But I don't see what you mean

idk if you've played warframe but they did a pretty major overhaul of damage types a while ago and if you did something similar there, there's just a risk of someone modifying the "armor" entries without updating the description to reflect the changes is all

low hinge
#

I do not give a shit about someone hacking and modding my game

old elk
#

that is not what I was referring to but alright

#

which is why I said if you're not working alone :p

#

if you're working alone and trust yourself to maintain those descriptions, go for it

old elk
low hinge
#

Oh I see what you mean, yeah it's a pain to update all this UI info alone yeah

astral sky
#

parallelism goes brrr

old elk
#

but why do you need to do that in parallel

#

I have no idea how compatible regular C# threading is with Unity actually

astral sky
#

I've played modded RoR2 and its honestly god awful with mods and its all because of everything going through the main thread and garbage collection

old elk
#

strings are just char arrays btw, and chars are just bytes (or shorts depending on character set)

astral sky
old elk
astral sky
old elk
#

however I'm willing to bet that part of it's just people using bepinex and writing dogshit code lol

astral sky
#

But the catalogue problem I mentioned earlier? If you have like 10 RoR2 mods the initial game load goes from 1 minute to... 6 or even 7

old elk
#

A big problem I've noticed with certain games is also that the developers think they're clever and implement like...a mini ECS - Rimworld is super guilty of this - and then it performs like total shit

astral sky
#

it's REALLY bad

night harness
#

People can write good code with bepinex ๐Ÿ˜ฆ

old elk
night harness
old elk
#

I have a skyrim modlist with 1100 mods that loads in like 30 seconds

astral sky
old elk
#

you actually do

#

:)

astral sky
#

Has been a year or two since I play Rimworld

#

oh

old elk
#

Yeah. Use a mod manager lmao

rigid island
#

this should probably be a thread at this point tbh..

#

might discourage someone posting a Q

old elk
#

fair, I usually try to avoid threads because they hide shit from people coming in who might want to contribute to the conversation

night harness
#

bepinex modding has a massive problem with asset modding because people do it non coroutine or async so because bepinex loads up each plugin one by one the entire upcoming modlist has to wait for the previous mod to finish loading their bundles before the next mod in the line can even start

lethal company can hit like 5-10min cuz of silly modders doing that kinda shit

old elk
#

but you're also correct that someone might not wanna post a question mid conversation

rigid island
#

true but also this veering offtopic too

astral sky
#

Maybe something like "flexible easy asset authoring" or something...

old elk
#

which brings me back to why I wanted to write a moddable game in the first place

to minimize the risk of people accidentally creating huge load times lmao

astral sky
old elk
#

i'm working on a game that's kind of a mashup of rimworld/kenshi/borderlands and i can 100% see that kind of thing having a modding scene

not that I'm deluding myself into thinking it'll be the next big thing, but it can't hurt to make my own game easier to add content to, for my own sake at least

astral sky
#

Apparently it just bundles everything automatically if they are referenced in any scene, so you don't really get a saying into what goes or doesn't where or any kind of organization at all. It really makes me worry about future content delivery because with standard Unity you can just ship a new asset bundle or addressable in an entirely new "folder" and be done with it...

old elk
#

at least that's what this sounds like to me

#

We had a big problem at my last job where we had multiple systems competing for GPU memory with 0 information shared between them so

astral sky
#

I really hoped that Unity 6 would be a soft-reset and they said that they aren't doing it that and will keep everything legacy and.. yeah

#

Like please, just get rid of the old input system

old elk
#

leaving it in is fine imo, considering you can disable it through the editor

safe fable
#

okay why are dealing with canvas/panels/ UI so complicated xD.
what you see is NOT what you get... >.<

old elk
#

old or new UI?

safe fable
#

im just using the regular one..? not sure about whats old or not as im new to Unity

old elk
#

Also holy shit it's the nosam cutter from warframe (that was a joke please do not crucify me)

safe fable
#

LMFAO

old elk
safe fable
#

ohh so i should probably look into this UI toolkit thing

old elk
#

I'm not familiar with UI toolkit myself but it sounds like the older one

safe fable
#

oh wait

old elk
#

they have different use cases

#

UI Toolkit is good for UI-driven applications from what I'm seeing

astral sky
#

I'm actually unsure about UI Toolkit's performance when compared to uGui, I think it's better??

old elk
#

UI perf has honestly never been something I've considered

#

Only time I ever ran into an issue with UI performance was using ImGui at work and accidentally loading 42 GB worth of data into a window

#

I was writing an asset browser

safe fable
#

Well i have a half working debug console that I made but the UI is fucked (but it gets the job done, since i can just copy the logs) and i also want to create an inventory UI (the system works, the items just save in backend and cant be displayed yet)

Maybe looking into this UI Toolkit would be good for those as they only need to be simple

old elk
#

For an inventory you might wanna consider Unity GUI

#

I'm biased though

#

Big thing with unity GUI is easier script references for individual components

safe fable
#

thats what ive been trying to do but its hurting my brain because in scene view it looks great/game view, but actually IN GAME its a mess and NOT what i get lol

#

ill give an example one sec ill send ss

old elk
#

resolution issue maybe?

safe fable
#

wait i wont send a SS actually cuz i deleted it all in rage

old elk
#

sounds like you might wanna check up on your anchor/pivot

safe fable
#

but you get the point lol

safe fable
#

so, should all my UI elements be on one canvas ?

astral sky
old elk
#

I had a bit of a "what the FUCK" moment when I was first implementing my UI code and I wasn't sure why Unity needed a Vector2 for anchor x/y instead of just one vector2 containing the relative x/y of the anchor point

astral sky
#

Any changes in a Canvas makes that canvas dirty, and it will be redrawn

old elk
#

yep

safe fable
#

ooooo okay

old elk
#

I mean for like a HUD you can use one canvas

astral sky
#

You can, however, make different canvases for different elements, I think it'd be fine then

old elk
#

But I'd use a separate one for stuff like in-world elements

#

you'd need a separate canvas per in-world element, to be clear, not one for all of them

astral sky
#

What I've seen some games do is have one giant canvas that just covers the entire screen and then inside they draw things, kinda like flexboxes

safe fable
#

im gonna add an inventory button like this. shoudl this be on the same canvas as the roll button then ? but have a child canvas inside the main one or something?

old elk
#

you thinking of something like rendering to a rendertarget?

astral sky
safe fable
#

or 1 canvas then a bunch of panels inside that canvas

#

idk

old elk
#

nobody will stop you don't worry

astral sky
#

Yeah just don't put too many elements into one canvas

old elk
#

well more like - what does that offer for something like a HUD lmao

astral sky
#

Well you can disable the entire hud by hiding the root canvas that's for one

#

and if you want to make splitscreen or something similar you resize the canvas' size to half and everything inside resizes accordingly

old elk
#

isn't that just how you normally do UI

#

in a hierarchical model

safe fable
#

UI's are confusing in unity >.<

old elk
#

i have a canvas node and then it has child nodes for the HUD elements

old elk
#

There's always some aspect of every UI framework that just makes me want to cry

safe fable
#

should i not even be using a panel here tbh

#

i mean its just a button

#

idk

#

i could put all the buttons as childs of the canvas , would that be better?

#

and only use panels for like.. .the actual inventory or whatever i need?

#

no idea what a good workflow is for this

#

or i could jsut try everything until i get it ;p

old elk
#

I mean if you right click and just add a button without having an existing canvas, it'll generate a canvas with the button as a child of that canvas

#

and the text as a child of the button

safe fable
#

i mean in reference to the panel mostly

old elk
#

I have never in my life used a panel if I'm honest

safe fable
#

i guess for this i dont need it

old elk
#

but also I don't do much UI stuff in Unity

safe fable
#

UI is stupid

#

i ahte it

#

):

#

DAWODJAWI

old elk
#

if it's similar to a WPF pane, though, it'd make more sense

safe fable
#

derstijkougejrsigdrsijodsrgjiogdsriojdsgorijidjsogrpijodsgprijodsgrijosdgrijosdgr

#

thats my ted talk, thanks

old elk
#

understandable, have a day

#

seems like panels are just collections of components, idk

safe fable
#

a panel will be good when i need to list/display inventory items

old elk
#

okay yeah a panel is apparently just a shortcut to creating a UI gameobject with a recttransform, image component and canvas renderer

safe fable
#

but maybe not so much for just a button that rolls ๐Ÿ˜„

old elk
#

you do not need one to add a button to your canvas

#

okay actually that part about reflection cacheing might be a clue as to why Rimworld runs more slowly just from adding mods ๐Ÿ’€

#

but now I'm stuck on "how do I handle object def classes added by mods"

astral sky
#

I read about how there was a whole drama about the reflection caching in one community

#

funnily enough

#

Because a lot of users kept complaining about performance?

astral sky
zinc tartan
#

i might be wording this completely wrong but is there a way i could get a vector 2 from a number of degrees ex: getting 1, 0 from 90 degrees (im sure thats not right, just an example of what im trying to accomplish)

cold parrot
safe fable
#

LONG STORY SHORT, it looks like everything shoudl be working

#

but its not

#

its not a code issue, the logs show and work and are available, and confirmed because im able to copy them. but i cannot see them. as you can see in the screenshot though, i (hopefully) have it positioned and everything correctly

#

its instancing the prefab for the log entries

sage heart
#

yo im trying to make dark fantasy game. and i need help. im new and i wanna make small but great game so if yall can help dm me

somber nacelle
safe fable
somber nacelle
#

!code

tawny elkBOT
safe fable
#

i also linked a screenshot of the reference fields

somber nacelle
#

and is this issue only happening in a build, or does it happen in the editor as well?

safe fable
#

haven't even bothered checking in editor, let me do that rael quick

#

yeah, in both

#

i would think it has something to do with the prefab

#

im just not sure.. what ๐Ÿ˜„

somber nacelle
#

and you're certain there are no relevant errors in the console

#

or any errors at all for that matter

safe fable
#

yeah thats all good

#

not sure if it helps mch but this is my full heriarchy

#

then the text goes child of content

somber nacelle
sage heart
#

yo do yall have script for mevement

#

crouch jump and other thing

somber nacelle
#

this is not a place to get handouts. go !learn and make it yourself

tawny elkBOT
#

:teacher: Unity Learn โ†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

safe fable
#

so its definitely like, working

somber nacelle
#

show the inspector for one of the objects that gets added at runtime

safe fable
#

ok ok

#

those logs are exactly as should

#

all of them

#

so the text works too

#

๐Ÿ˜„

#

which is all good news

somber nacelle
#

well it's currently disabled, you need to look at it while it is enabled

safe fable
#

LMFAO

#

idk why i did that

#

welpo

#

the position

#

is

#

-1xxxxx

#

well

#

i guess thats just the scrolling nvm

#

thats fine

sage heart
#

bro if yall have normal movement js dm me. these learning thing is laggy asf . cant even hear what hes saying

sage heart
somber nacelle
safe fable
sage heart
safe fable
#

you must be trolling right now

#

@sage heart

sage heart
#

what?

#

im new i need something to start with

shadow wagon
lean sail
#

start by learning lol, instead of demanding people write your code for you

safe fable
#

@somber nacelle lol

#

i see

#

so thats exactly whats happening

sage heart
lean sail
sage heart
#

if u want money just say it im gonna give u 0.50$ for ur meal today

safe fable
shadow wagon
somber nacelle
safe fable
sage heart
lean sail
safe fable
shadow wagon
#

why learn to be a programmer, if you just want to take shortcuts and that save you programming

safe fable
#

you 100% are trolling

sage heart
somber nacelle
sage heart
#

im starter

#

and yall are making me talk

sage heart
#

i need starting point to learn

#

i cant create things from air

safe fable
#

learn C# , the basics of it

#

learn what programming is

sage heart
somber nacelle
dense pasture
#

kids these days sheesh

sage heart
#

i jsut asked for help and im getting jumped

shadow wagon
#

Learn C# basics in 1 hour! โšก This beginner-friendly tutorial gets you coding fast. No experience needed.

โค๏ธ Join this channel to get access to perks:
https://www.youtube.com/channel/UCWv7vMbMWH4-V0ZXdmDpPBA/join

๐Ÿš€ Ready to master C#?

โ–ถ Play video
sage heart
#

ty this server and there comunity

sage heart
#

nothing more

#

done

lean sail
dense pasture
#

when i was your age we didnt have youtube tutorials to learn. you just beat your head against brick walls until shit worked you know

shadow wagon
safe fable
#

๐ŸŒ Get the Premium Course! https://cmonkey.co/csharpcompletecourse
๐Ÿ’ฌ Learn by doing the Interactive Exercises and everything else in the companion project!

โค๏ธ Watch my FREE Complete Courses https://www.youtube.com/watch?v=oZCbmB6opxY
๐ŸŽฎ Play my Steam game! https://cmonkey.co/dinkyguardians
๐ŸŒ Get my Complete Courses! โœ… https://un...

โ–ถ Play video
sage heart
somber nacelle
sage heart
dense pasture
#

or you bought those giant ANSI C encyclopaedias

safe fable
somber nacelle
dense pasture
#

and you figured it out

sage heart
safe fable
#

ok ok

somber nacelle
#

then get to learning

safe fable
#

you have to understand , programming is not writing code. its PROBLEM SOLVING. and you are refusing to solve a problem

sage heart
#

whereeeeeeeeee

shadow wagon
dense pasture
#

you understand having people do it for you you'll still understand none of it and wont get anywhere

lean sail
sage heart
dense pasture
mossy flare
#
        velocity = Vector3.SmoothDamp(velocity, direction * speed, ref velocityRef, smoothing);
        cc.Move(velocity);```
I'm so confused. This should be frame independent, right? Why is my speed changing with the game's time scale?
safe fable
sage heart
dense pasture
#

my first project was a casino simulator in BASIC lmao

#

age 12

safe fable
mossy flare
#

Yes

dense pasture
#

game dev is p[robably the best way to learn code

safe fable
lean sail
shadow wagon
dense pasture
#

it wont be ghost of tsushima but you gotta start with the fundamentals and CLI code will get you very deep into understanding OOP

dense pasture
sage heart
lean sail
#

Also theres no off topic in the channel, the conversation you all are having isn't related to helping anyone and the person clearly wasn't even reading half the messages since they were linked 6 times for resources and only saw 1.

dense pasture
#

gpt found me all kinds of stuff i didnt know about xNode

#

and the official discord is dead lol

mossy flare
dense pasture
#

its a great assistant but i wouldn't use it for the whole project

safe fable
#

@mossy flare multiply by delta time

#

if u haven't

mossy flare
#

Multiply what by deltatime

lean sail
mossy flare
safe fable
#

this is how mine works @mossy flare