#archived-code-general

1 messages · Page 262 of 1

crisp scarab
#

the biggest map would have around 22 walls

west lotus
#

Correct me if Im wrong but the amount of subscribes does matter and its not cheaper or identical to lets say a method call

crisp scarab
#

events flew over my head when thinking this, i could try, thanks

west lotus
fervent furnace
#

how the array element looks like doent affect the length of the array
i have a large number 12345678987654321 store in a long long[], it is still one element

knotty sun
west lotus
crisp scarab
west lotus
knotty sun
west lotus
#

Each wall can hold its cubes as children

#

Maybe he wants to destroy his walls in some way we dont know

knotty sun
#

each wall should have 1 cube unless there is a damn good reason for it not to have

sacred plaza
#

Yeah, so that number of cubes won't be much of an issue. But you can do this pretty efficiently by simply grouping the walls into hierarchies where either each wall segment has the same parent object or each cardinal direction is stored into a common hierarchy. Disable the parent object and all children will be skipped.

crisp scarab
#

i wanted explosions to affect walls, but having one cube per wall and 2 meshes, a full one and a broken one is also a possibility

sacred plaza
#

You can replace the wall segment being exploded into cubes when it's being exploded.

knotty sun
#

indeed

#

with rigidbodies to make it even more impressive

west lotus
#

And dont forget to object pool 🤣

knotty sun
#

absolutely

west lotus
#

I think I have optimized more things with object pooling than anything else in my career

sacred plaza
#

4k cubes all things considered is still not a lot.

west lotus
#

Definitely not a lot not

#

Well again depending on platform

crisp scarab
#

i will try and test both approaches, grouping in object hierarchy then disable the parent and one big cube per wall exploded into cubes

west lotus
#

For mobile I would consider it a lot

crisp scarab
#

thank you guys

hard viper
#

honestly the biggest optimization is just using event delegates to avoid calling a function an unnecessary number of times

#

Turns out there is less work to do when you just… don’t do as much work.

#

But that’s more of an architecture thing.

real plume
#

!code

tawny elkBOT
lunar python
#

are all the cubes filled or just some vertices

#

just curious

crisp scarab
#

the cubes on the borders are filled, the inner cubes are quads

#

applies to both floors and walls

swift falcon
#

Would anyone be able to help with fiddling with this tutorial : https://github.com/zigurous/unity-pacman-tutorial
In the tutorial the guy decides to just rotate pacman around instead of changing the actual sprite animations and I'm just not sure what the best way to do that would be based on what he's got going on. I need different animations because my team is making a sort of 2.5D pacman and would need 1 animation for each direction.

GitHub

🟡🍒 Learn to make Pacman in Unity. Contribute to zigurous/unity-pacman-tutorial development by creating an account on GitHub.

woven veldt
#

is it possible to slerp/lerp in ECS?

heady iris
#

sure. those are just math functions

#

this will be Burst-compatible

#

slerp is also available

vast stump
#

Hello Im looking for someone who knows unity who can eventually help me in a vc since I have some problems

somber nacelle
#

also don't crosspost

vast stump
# somber nacelle just ask your question here. nobody is going to join you in voice chat to help y...

new problem: When I start the game the zombies now fall into my turret and do not follow the waypoints anymore. I also would like to know how I can make the turret automatically aim at the zombies. this is the code right now

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

public class Tower : MonoBehaviour
{
    public float range = 10f;
    public float fireRate = 1f;
    public GameObject projectilePrefab;
    
    private Transform target;
    private float fireCooldown = 0f;

    void Update()
    {
        if (fireCooldown > 0)
        {
            fireCooldown -= Time.deltaTime;
        }

        if (target == null || Vector3.Distance(transform.position, target.position) > range)
        {
            // No target in range, find a new target
            FindNewTarget();
        }

        if (target != null && fireCooldown <= 0)
        {
            // Rotate turret to face the target
            RotateTurret();

            // Shoot at the target
            Shoot();
        }
    }

    void RotateTurret()
    {
        Vector3 targetDirection = (target.position - transform.position).normalized;
        float angle = Mathf.Atan2(targetDirection.y, targetDirection.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
    }

#
 void FindNewTarget()
    {
        Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, range);
        float minDistance = float.MaxValue;
        Debug.Log(colliders.Length);

        foreach (Collider2D collider in colliders)
        {
            if (collider.CompareTag("Zombie"))
            {
                Debug.Log("New Zombie Detected");
                float distance = Vector3.Distance(transform.position, collider.transform.position);
                if (distance < minDistance)
                {
                    minDistance = distance;
                    target = collider.transform;
                }
            }
        }
    }

    void Shoot()
    {
        fireCooldown = 1f / fireRate;

        // Instantiate the projectile and set its direction
        GameObject projectile = Instantiate(projectilePrefab, transform.position, transform.rotation);

        // Calculate direction to the target
        Vector3 direction = (target.position - transform.position).normalized;

        // Move the projectile towards the target
        Rigidbody projectileRb = projectile.GetComponent<Rigidbody>();
        projectileRb.AddForce(direction * 10f, ForceMode.Impulse);
    }
}
#

its a turret for a Tower Defence game

heady iris
#

Stop crossposting. Posting in multiple channels like this is spam.

#

(note that the code channels are the appropriate place to ask about this, so it's fine to post here. just don't post in other channels as well)

indigo hound
#

Hey there. I'm making a 2D platformer game which needs to be quite precise in collision detection. Therefore I have made my own collision detection system using raycasts. In the picture below I added some more visualisation to make my problem/question more clear. So my character has a square hitbox (green box) with which I use the bounds to calculate the ray origin points (red dots). These are inset by a small amount to prevent bugs etc, so they don't start exactly on the edge of the box.

The character has rays going both left and right at all times to detect collisions on the left and right, as seen on the left side of the picture. When my character runs to the right, I adjust the length of the right rays to match with his velocity. I do this so if a wall is detected I can us the RacyashtHit2D.distance to align the character perfectly with that wall. This works fine, but I'm not sure what to do with the left rays while running right. Do these have to be turned to the right and adjusted to the velocity too? What would be best?

#
float rayLength = Mathf.Abs(moveAmount.x) + skinWidth;
for (int i = 0; i < 3; i++)
{
    Vector2 rayOrigin = new();

    if(i == 0) rayOrigin = raycastOrigins.rightTop + Vector2.up * moveAmount.y;
    if(i == 1) rayOrigin = raycastOrigins.rightBottom  + Vector2.up * moveAmount.y;
    if(i == 2) rayOrigin = raycastOrigins.rightCenter + Vector2.up * moveAmount.y;

    RaycastHit2D[] hitsRight = Physics2D.RaycastAll(rayOrigin, Vector2.right, rayLength, collisionMask);
    Debug.DrawRay(rayOrigin, Vector2.right * rayLength, Color.green);
}

Here is my code for the right rays, where the skinWidth is the small inset I was talking about

upbeat hill
#

Hey guys, is there a channel to ask questions about cinemachine?

somber nacelle
#

have you bothered checking? you know id:browse exists, right?

upbeat hill
modern creek
#

Anyone having any issues starting unity (license errors)? I can't google up any errors/outages with the license servers but my client isn't getting a response and so I can't start unity

#

(license is definitely still valid)

#

I suppose I'll try that?

somber nacelle
#

this is a code channel

chrome spoke
#

I have a level editor, a menu, and a scene that contains a list of all user-created level files to load from. I am getting the following errors
1- I get an error when I try to load into a level (it still opens the level editor)
2- I get an error when I try to place objects (this did not happen before I changed the system to use the save and load feature)
3- I get an error when I try to save a file from the editor

PersistenceManager.cs code snippet

private void SetupFloorplan()
    {
        this.sceneData = dataHandler.UnpackSceneToLoad();

        // if no data can be loaded, initialize to a new game
        if (this.sceneData == null)
        {
            Debug.Log("No data was found.");
        } else {
            // set sceneData.fileData
            string theDate = System.DateTime.Now.ToString("MM/dd/yyyy") + "_" + System.DateTime.Now.ToString("hh:mm:ss");
            // PROBLEM ON LOAD AND CREATE NullReferenceException: Object reference not set to an instance of an object
            FileData newFileData = new FileData(sceneData.fileData._name, theDate, sceneData.fileData._size);
            sceneData.SetFileData(newFileData);
            GameObject.Find("PlacementSystem").GetComponent<PlacementSystem>().LoadFromSceneData(sceneData);
        }
    }
#
ObjectPlacer.cs code snippet

public int PlaceObject(GameObject prefab, Vector3 pos, bool rotate, Vector2Int scale)
    {
        PlacerObject newPlacerObject = new PlacerObject(prefab, pos, rotate, scale);
        GameObject newObject = Instantiate(prefab);
        newObject.transform.position = pos;
        if (rotate) { newObject.transform.Rotate(0, 90, 0); }

        Vector3 newScale = newObject.transform.localScale;
        newScale.x = scale.x > 1 ? scale.x : newScale.x;
        newScale.z = scale.y > 1 ? scale.y : newScale.z;
        newObject.transform.localScale = newScale;
        
        placedObjects.Add(newObject);
        // PROBLEM ON PLACE NullReferenceException: Object reference not set to an instance of an object
        placerObjects.Add(newPlacerObject);
        return placedObjects.Count - 1;
    }
FileDataHandler.cs code snippet

public void Save(SceneData sceneData)
    {
        // PROBLEM ON SAVE second argument cannot be null
        string fullPath = Path.Combine(pathBuilds, sceneData.fileData._name);
        try
        {
            Directory.CreateDirectory(Path.GetDirectoryName(fullPath));

            string dataToStore = JsonUtility.ToJson(sceneData, true);

            using (FileStream stream = new FileStream(fullPath, FileMode.Create))
            {
                using (StreamWriter writer = new StreamWriter(stream))
                {
                    writer.Write(dataToStore);
                }
            }
        }
        catch (Exception e)
        {
            Debug.LogError("Error occured when trying to save data to file: " + fullPath + "\n" + e);
        }
    }
#

anyone know where I'm going wrong?

stark sun
#

How can I add 90 degrees to hips.AddForce(hips.transform.forward * strafeSpeed); because my hips.transform.right is not my left and right. It's up and down

lean sail
# chrome spoke anyone know where I'm going wrong?

Null reference errors are always the same in terms of debugging steps. First find out exactly what is null, then find out why it is null. Maybe race condition, unassigned variable, could be any reason.

#

Im surprised you wrote all that code tbh before being able to solve those errors, did you write this yourself? Is it AI code

lean sail
chrome spoke
stark sun
unkempt meadow
#

Ok so my camera jitters when following my character controller player but only in the build. Works perfectly fine in editor. It's not the update method, I tried that.

It probably couldn't be that anyway given it's smooth in the editor. Does my build need vsync or something? I don't know what to look at

lean sail
stark sun
lean sail
chrome spoke
# lean sail So you didnt write the code? Im confused what you mean it's a big project you ar...

Right, I was just answering the question. I did write the project, but I'm adding new functionality into the existing project I previously made. It's around 30 cs files, so I was just trying to only give the problematic lines.
The third error isn't null error though, so I think I'll still be stuck on that one

ArgumentNullException: Value cannot be null.
Parameter name: path2
System.IO.Path.Combine (System.String path1, System.String path2) (at <b5ac4fa8faf34bc9be9b9c54f8ce8a43>:0)
lean sail
modern creek
#

We have a project in Unity 2021.3 and we want to update to 2022.3. My plan was to clone our repo into an entirely new directory that uses the new version so that hotfixes in 2021 can still be made without needing to rebuild the library twice (once to boot into 2021, once to boot back into 2022).

I made cloned the repo into a new directory, branched git, upgraded unity in that branch and fixed all the configuration stuff, and patted myself on the back.

Then I wanted to work on some 2021 work so I closed unity 2022 and opened 2021 (pointing at the "old" repo directory which was always 2021). I was surprised when a library rebuild was triggered:

[ScriptCompilation] Requested script compilation because: Assembly Definition File(s) changed
[ScriptCompilation] Requested script compilation because: Assetdatabase observed changes in script compilation related files
Clearing Bee directory 'Library/Bee', since bee backend hash ('Library/Bee/bee_backend.info') is different, previous hash was 241a572c16cb9bf3430ef298ed253734c257e34eb5cd139b490776a0a556aef1 (Unity version: 2022.3.18f1), current hash is 68e8537ffe8d9d5548d00a71da3d23d769decaf2e00f40c6ce196e1701b63cac (Unity version: 2021.3.10f1).
Starting: D:\Program Files\Unity\Unity 2021.3.10f1\Editor\Data\bee_backend.exe --profile="Library/Bee/backend_profiler0.traceevents" --stdin-canary --dagfile="Library/Bee/1900b0aEDbg.dag" --continue-on-failure ScriptAssemblies
WorkingDir: D:/projects/unity/sapling-client

Did I F something up or am I somehow not aware of some common area these hashes are stored (between instances of unity)?

chrome spoke
# lean sail It does literally say "Value cannot be null"

yeah, I guess it is still a null error variation.

I think my issue is with trying to convert my SceneData object to and from files using the JsonUtility, but I am still not sure what it is that I am doing wrong

save method

public void Save(SceneData sceneData)
    {
        string fullPath = Path.Combine(pathBuilds, sceneData.fileData._name);
        try
        {
            Directory.CreateDirectory(Path.GetDirectoryName(fullPath));

            string dataToStore = JsonUtility.ToJson(sceneData, true);

            using (FileStream stream = new FileStream(fullPath, FileMode.Create))
            {
                using (StreamWriter writer = new StreamWriter(stream))
                {
                    writer.Write(dataToStore);
                }
            }
        }
        catch (Exception e)
        {
            Debug.LogError("Error occured when trying to save data to file: " + fullPath + "\n" + e);
        }
    }

load method

public SceneData Load(string filename)
    {
        string fullpath = Path.Combine(pathBuilds, filename);
        SceneData loadedData = null;
        if (File.Exists(fullpath))
        {
            try
            {
                string dataToLoad = "";
                using (FileStream stream = new FileStream(fullpath, FileMode.Open))
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        dataToLoad = reader.ReadToEnd();
                    }
                }

                loadedData = JsonUtility.FromJson<SceneData>(dataToLoad);
                File.WriteAllText(pathSceneToLoad, "");
            }
            catch (Exception e)
            {
                File.WriteAllText(pathSceneToLoad, "");
                Debug.LogError("Error occured when trying to load data from file: " + fullpath + "\n" + e);
            }
        }
        return loadedData;
        SceneManager.LoadScene("Floorplan_Editor");
    }
simple egret
#

Your code does not compile. void Load() contains a return loadedData; which is not possible
Do not alter the code when posting it.

modern creek
#

Not sure what's confusing..? I also agree with @lean sail that it seems like you didn't write this and generated it instead for a couple reasons - it looks generated, but is also more challenging to write then a someone who can't find a NRE issue (your issue is on the first line of Save(), btw - sceneData or sceneData.fileData is null).

No worries with the AI thing (I use copilot myself) but if you don't know how to debug something, you should probably ask that first. Put a breakpoint on that line, find out if sceneData or sceneData.fileData is null, and why. fileData doesn't appear to be properly named (another pointer towards generated/AI code), nor is it a field in Unity.Entities.SceneData: https://docs.unity3d.com/Packages/com.unity.entities@0.0/api/Unity.Entities.SceneData.html

#

It's AI code and it's just... mangled.

#

Like... your catch clause of your Load() function has a file.writealltext? that makes no sense whatsoever..?

lean sail
#

Yea I dont really know how to respond because this error is one of the first things you should learn. I don't know how you write all this code without knowing the basics

modern creek
#

This is why AI won't take the jobs of programmers.. because it "looks" right but is actually mostly nonsense.. and complicated nonsense at that

#

Real beginners (who don't yet know how to figure out NRE issues) don't use try/catch with nested using statements ...

chrome spoke
heady iris
#

Do not alter the code when posting it.

#

Ever.

#

We need to see exactly what you are seeing

chrome spoke
#

But like under that same concept, I may as well post all 30 files of code

heady iris
#

that's why I always ask people to share full scripts

heady iris
#

but obviously I do not need to see literally every .cs file in your project

#

code in a single script tends to go together

lean sail
#

If you feel that all 30 files are related, your code is so coupled they are basically holding hands

#

Like a kindergarten class

modern creek
#
string fullPath = Path.Combine(pathBuilds, sceneData.fileData._name);

Tell us about that line - because that's what's broken (and shouldn't/won't even compile..?)

#

sceneData doesn't have a field named fileData

simple egret
#

It's usually very precise requests at first, and if the issue is more global we ask to post more code.
Start with the error. It contains a stack trace, pointing to the exact line of code the exception occurred on. Post that entire file. If needed you will be asked to post other files.

heady iris
heady iris
#

go check your last-modified dates on the files to be sure..

modern creek
heady iris
modern creek
#

worked on the 2022 version all morning, then closed it, opened the 2021 version and was very surprised for it to rebuild

simple egret
#

Maybe you committed the entire Library folder to the remote (bad or misplaced gitignore file?)

modern creek
#

(didn't change the editor version in the dropdown there)

#

Nope, did no commits, actually, even..

vale drum
#

Hub can show same project name , check favorite icon in the list ( other path but same project/copy)

modern creek
#

Basically my process (yesterday) was:

  1. Create an empty directory, sapling-client-2022.
  2. Clone the repo into that directory.
  3. Branch from main into something like feature/upgrade-unity-2022
  4. Install unity 2022.3.18f1
  5. Open that new directory with unity 2022 - get a library rebuild (as expected).
  6. Work on that branch in 2022. Stash changes.
  7. Close 2022, open 2021 (pointing at old directory)
  8. Library rebuild!?
#

(and definitely haven't committed the /library directory - I think for this project that directory is like 4gb+)

chrome spoke
heady iris
vale drum
#

sort to find dupplicates, in diffrent folder, at same name than check one with star favorite and hit ... open folder

modern creek
#

snipped out some personal info but ... startup logs look fine? boots into 2021.3, pointed at the correct directory, etc

#

I might even be able to dig up the editor log from the last boot into 2022.3 just to verify that i opened it while pointed at the correct dir

#

oh, nevermind.. unity puts all editor log files into a common directory 😦

heady iris
#

editor-prev?

modern creek
#

overwritten already - had some other issue

heady iris
#

ah, okay

modern creek
#

(license server down or something)

heady iris
#

hm, I can't think of any other reason for that to happen. You could try and reproduce it with a new project

modern creek
#

Yeah, it's.. a stumper.. I think maybe I goofed something.. I'm only hesitant to try to repro because the library build for this project takes forever (like 35 minutes)

heady iris
#

the Hub is not infallible, for sure (it could completely obliterate new projects if you logged in via the editor for quite a while)

#

create new project -> sign in through the editor -> close editor -> open editor -> project is overwritten with the original template

#

oops

modern creek
#

yeah I have some.. back and forth in a unity forum thread about the hub going on..

#

the whole administrator access required UI/UX (for the hub) is .. a little bumpy

loud dome
#

man i really need some help, i've been trying to find and fix this for 8 hours, can anybody help me doing a melee attack in an rpg?

swift falcon
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class ReturnToMainMenu : MonoBehaviour
{
    // Start is called before the first frame update
    public void mainMenu()
    {
        SceneManager.LoadSceneAsync(0);
    }
}

Any clue why this won't take me back tomy main menu and just restarts my level? Script is attached to main menu, button is attached to UI Canvas-> Canvas

hazy bison
#

hey, anyone can help me with the JsonHelper? its a json serialization helper and its just giving me empty json strings

heady iris
#

perhaps that's the wrong scene

swift falcon
heady iris
hazy bison
heady iris
#

Perhaps your button is targeting the wrong thing

hazy bison
# heady iris I have no idea what that is, so you'll need to show us.
public static class JsonHelper
{
    public static T[] FromJson<T>(string json)
    {
        Wrapper<T> wrapper = JsonUtility.FromJson<Wrapper<T>>(json);
        return wrapper.Items;
    }

    public static string ToJson<T>(T[] array)
    {
        Wrapper<T> wrapper = new Wrapper<T>();
        wrapper.Items = array;
        return JsonUtility.ToJson(wrapper);
    }

    public static string ToJson<T>(T[] array, bool prettyPrint)
    {
        Wrapper<T> wrapper = new Wrapper<T>();
        wrapper.Items = array;
        return JsonUtility.ToJson(wrapper, prettyPrint);
    }

    [Serializable]
    private class Wrapper<T>
    {
        public T[] Items;
    }
}
swift falcon
#

heard.

heady iris
#

I'd suggest just using Json.NET if you're doing anything non-trivial with serialization

#

JsonUtility is extremely limited

#

as you can see, it requires lots of weird workarounds -- wrappers and whatnot

hazy bison
# heady iris JsonUtility is extremely limited

yea this script aims to fix some of the limitatins by wrapping everything into "items" so your entries wont be on top level. this allows for basic read and write to an already existing json

swift falcon
hazy bison
#

im just doing extremly light work and this script seems to work for everyone i saw online. im just having a very strange problem as it seems

heady iris
swift falcon
heady iris
#

this is how it'd look when filtered

#

If there is indeed no log entry, then perhaps you have multiple buttons overlapping there

heady iris
swift falcon
swift falcon
#

Rest is text or images.

heady iris
#

pretty sure you have all log entries filtered there. the numbers will still go up when messages are logged either way

#

(maybe your color scheme is just different tho)

swift falcon
#

I just realised that's probably useless because of my having named everyting lol

#

Made sure all my stuff wasn't filtered and still nothin... Hmm. Must be something somewhere else. I don't know why it would restart the game if it did nothing at all.

#

Probably cause of the way I set up the end screen to test it, there's some code after the canvas pops up that could just be continuing or something. Thanks for trying to help either way

heady iris
#

So you confirmed you are not getting anything in the console, correct?

swift falcon
#

Yeah.

heady iris
#

You should now search your project for everywhere that you interact with the SceneManager class

#

click it and hit shift-F12 to get a nice list

#

barring any truly heinous creativity, this should be every place that actually loads a scene

#

that'll give you something to start with

swift falcon
#

How do I search the whole project? Was unaware I could do something like that lol

heady iris
#

This is in your code editor.

#

It's not related to Unity at all -- you're just asking your IDE to find all uses of something

swift falcon
#

Ah okay

heady iris
swift falcon
#

I am newish to Visual Studio, didn't use it before starting with unity

heady iris
#

shift-F12 is great for quickly understanding who uses something

#

and F12 takes you to the definition of something

hazy bison
heady iris
#

well, yeah, if you write to file X, and file X already exists, you're overwriting file X

hazy bison
#

FIleMode.Append maybe better idea?

heady iris
#

that would mash two JSON objects together into one file

#

which would be invalid JSON

#

what are you actually trying to accomplish here?

hazy bison
#

ye hehe

hazy bison
heady iris
#

well, your code does exactly that

#

so be more specific

#

are you trying to add to existing data?

hazy bison
#

example: i input name into input field, i t appends the name into json

heady iris
#

if so, deserialize the object, modify the object, and serialize the object

heady iris
#

What are you trying to make your game do?

hazy bison
#

store this data into a json. name will be unique so there is the unique key

heady iris
#

okay, so you need to serialize a Dictionary<string, TeleportJson>

#

if you want to add another TeleportJson to the saved data, you must read the data, modify the dictionary, and save it back to the file

#

You could also just serialize a List<TeleportJson> and then make a dictionary out of it after deserializing it

swift falcon
#

Okay sorry I am so unfamiliar I couldn't even figure out how to get it to recognise all the files together but literally the only other place is the main menu scripts (idk why there's 2 but they're identical)

heady iris
#

you probably renamed MainMenuScript to MainMenu, but then saved the original file again

swift falcon
#

Yeah I must've lol

heady iris
#

figure out which one you're actually using and delete the other one

#

then add a log statement before that LoadSceneAsync

swift falcon
#

mmm Okay, now the return to menu button is working but is showing up when it's not supposed to. oh the joy of game making. I gotta run but I really appreciate your help so far!

calm talon
#

How could I set the bounding shape of a cinemachine to be the composite of PolygonColliders in a list?

#
private static List<PolygonCollider2D> colliders = new();
public void Foo() => 
  CinemachineConfiner2D.m_BoundingShape2D = (CompositeCollider2D)colliders; 

Something like the above

vestal crown
#

so i have a code thats adding points to an list based on the objects position, my issue is it is also making the y do weird things this was me holding my hand out and just walking straight

vestal crown
#

its litterally just this T-T

cosmic rain
vestal crown
#

i figured it outtt

#

it was my own code

#

or atleast a different code i put on the side saying id finish it after this one

#

jokes on me

swift falcon
#

Is there a way to enable/disable a button (image and text) in code?

vestal crown
#

like visibly or not allowing you to click the button

swift falcon
#

Visible

#

LIke, ope game over, press this button that now exists

vestal crown
#

would somethiing like this help?

swift falcon
#

Maybe, let me try. I kept seeing different syntax everywhere and none of it seemed to work.

#

Yeah this is the error I get when trying to do it like that.

vestal crown
#

did you put the button in the inspector?

#

you probably did im just checking

swift falcon
#

That was before I had got to that point, it didn't show up in the inspector yet, I think I had a typo somewhere else. I gotta figure out how to get VS to suggest that my sausage fingers fuck up some day.

fervent furnace
#

C# is case sensitive, btw not code general

swift falcon
#

Yeah, I've been learning C# through unity only, and Unity Pathway Tutorials at that.

#

It's a tough shtick lol

vestal crown
#

definitely can you send your code rq

#

if you want

swift falcon
#

Yes I can, I was just about to test it

vestal crown
#

oki

swift falcon
#

ope

#

That formatted wrong

#

I am not the programmer on this project really, I'm just in charge of getting UI working and we are working off of a youtube tutorial (class project)

vestal crown
#

can you show me the inspector for the script

#

i just tried the script and it should work

swift falcon
#

Sure, one sec.

#

I think it might be something about how the UI is layered, if I click anywhere on the screen after the end game popup the game also just restarts so somethin is fucky

vestal crown
#

wait can i see what is disabled on the button

#

like the image, button, etc

cosmic rain
swift falcon
#

haha

#

yeah

cosmic rain
#

Tell your team to be more careful with tutorials next time...😅

swift falcon
#

Button inspector, I've been fiddling with turning the actual who button off in the inspector vs in the code

swift falcon
vestal crown
#

everything should be enabled but the button itself

swift falcon
#

It's a very fast turn around project considering full time students so we were just rushing to get it done

swift falcon
#

I pressed paste and it didnt im sorry

vestal crown
#

and this didnt work?

swift falcon
#

Nope, I can show you (I am using place holder art and it's awful)

vestal crown
#

its cool, yes please

#

im kinda confused tbf

swift falcon
#

...... hmm

#

I just lost the game and went to take a screenshot

#

and now the button is there

vestal crown
#

i did all the same workings and it worked for me

#

maybe the issue is when that part of the script is being run

#

maybe add a Debug.Log("something"); there so you can see when its being ran

#

but dont forget to remove it

#

i keep forgetting T-T

swift falcon
#

Yeah, I'm gonna have to make some, I've been going and removing them lol

#

But this is what it looks like, I don't know how pressing printscreen made the button show up lol

cosmic rain
#

Or just use the debugger.

vestal crown
#

or that, i dont know how to use that so i dont

swift falcon
#

Okay I see, now that the button is not being disabled again when the round restarts (again idk what that happens on mouse click but its kinda not my problem), the button stays

#

but its like under the stupid image or something lol

cosmic rain
# swift falcon

I don't know if that's related to the issue, but you typically don't want any offset on the z axis on your ui.

swift falcon
#

UI is all 0 on Z, nothing there

#

How obnoxious

cosmic rain
swift falcon
#

Oh right, because I was trying it at different values lol

#

I tried making it super negative and super high to see if that would cause it to render before the image or something.

vestal crown
#

the way you have them layered does matter with UI

swift falcon
#

If I move the button down from the image it exists, so i guess I'll just have to take that.

cosmic rain
vestal crown
#

exactly

#

this guy knows ^u^

swift falcon
#

Yeah I did make sure the button is higher than the image, doesn't seem to care.

#

It's alright, I can deal with just putting it way below even if I think it's ugly, as long as it works.

cosmic rain
swift falcon
#

I had it both lower and higher, like I said at this point I'm basically just fucking with it in every way possible lol

cosmic rain
#

It's probably a combination of factors. You're probably fixing one issue but breaking it with a different thing

#

That's why you don't just "try everything unintelligibly"

swift falcon
#

That's fair lol

#

It's working well enough for now, thanks for the input guys o7

hazy bison
#

everytime i press a button it presses the next time once more than before

#

ah nvm

#

ik why

quartz folio
heady iris
#

Those are the only rules.

#

now, if you've shoved a SpriteRenderer into your UI, all bets are off

latent latch
#

I find it strange you don't have that sorting group control with UI compared to sprite renderers

#

beyond canvas groups

swift falcon
heady iris
#

So if you want to show a window with some buttons, parent the buttons to the window

#

The drawing order matches how you should arrange things to get good automatic layout

chrome trail
#

So I'm trying to set a rigidbody's velocity based on an animation event and it doesn't seem to be responding. Is there any reason this might be the case?

plucky obsidian
#

Is it possible to swap a CapsuleCollider2D between horizontal and vertical with a script?

leaden ice
#

Show code etc

#

And show what debugging steps you took

chrome trail
leaden ice
#

Step 1 did you make sure the code was actually running e.g. with a log statement?

chrome trail
#

I tried hitting the thing with an attack and it's not responding to the knockback it's supposed to be receiving

#

Yes, the code is running

#

It's just this one line that isn't doing what it's supposed to

leaden ice
#

Ok then either you're setting the velocity of the wrong object object or you simply have other code overwriting the velocity

#

For example maybe your other code is setting the velocity every frame

chrome trail
#

I figured it out. The animator is screwing with it somehow

heady iris
#

My understanding is that each animator layer will write to all properties that any of its animation states write to

leaden ice
#

Probably have write defaults on

heady iris
#

so even if you have a state that does nothing, the presence of another state that modifies your position will cause your position to be constantly set

#

nah, Write Defaults just changes what the animation writes when a state is active but not writing a specific property.

Write Defaults will write a fixed default value. If it's disabled, the animator just writes the last value it had.

heady iris
#

the animator is currently in a state that does literally nothing, and Write Defaults is off; the cube is impossible to move

#

New Animation makes it move from one place to another

#

If I turn Write Defaults on, the cube snaps back to its original position when I exit the "New Animation" state

#

Otherwise it just parks itself in place

#

I feel like the documentation could be more clear about this..

hybrid cloud
#

quick question regarding burst
is there any difference in performance between for and foreach loops?
this is in the context of a job that runs tens of thousands of times per frame

#

in my case when using the foreach im creating an iterator int before it and incrementing it every loop aswell

#

just trying to squeeze as much performance out of this job as i can get

chilly surge
#

A job as in, specifically a Unity Job system job, or are you just using it as a generic term for some amount of work?

hybrid cloud
#

the unity job system one

chilly surge
#

Are you using Burst compiler?

hybrid cloud
#

looping through a nativearray of float3's and doing stuff with them

hybrid cloud
chilly surge
#

Then I highly doubt it makes any difference.

hybrid cloud
#

thanks thumbsupsmiley

arctic pewter
#

hey, a somewhat fun problem. I have box with dimensions D. I have a player at a position P (all in 2 dimensions).
the player throws a laser that bounces off of every wall until it reaches some max distance. Is there any way to check if the laser ever goes back to the player position? Somewhat of a math problem, I know.

west lotus
hybrid cloud
#

job performs gravitational calculations for 10s of thousands of particles, each applying gravity for tens of thousands of particles

lean sail
hybrid cloud
#

n-body particle gravity sim

#

basically

hybrid cloud
lean sail
#

There is no mathematical formula, it bounces so they must use something that detects objects

west lotus
# hybrid cloud the latter

Thats good. Anyway I personally do not use foreach in jobs especially with Bust since I dont trust it. Actually I dont use foreach at all.

#

But Sarah shouldn’t you be doing your particle sim with compute shaders. Even for burst and the job system I think a cpu sim of that magnitude would be taxing.

hybrid cloud
#

with my current setup i get around 20fps with around 11k particles (when nothing is colliding) and im currently in the process of optimizing at as much as i can

hybrid cloud
#

i could be wrong though

#

would i be able to do stuff like gravitational calculations on the gpu while still being able to interact with the entities normally otherwise?

#

for example

west lotus
#

Define interact normally

hybrid cloud
#

i plan to let the player select individual particles (or groups) and change things about them in real time, like their mass, size, color, etc

#

through a ui

west lotus
#

Selecting individual particles seems like the hardest haha

#

Especially if they are being moved on the GPU

hybrid cloud
#

using dots to do this like i am would be as simple as changing property(ies) of the given entity(ies) through a monobehaviour (or i could make a system for it but you get what im saying)

west lotus
#

Oh your using ECS

quartz folio
hybrid cloud
#

if you want us to move it there lmk

hybrid cloud
#

also that meant to say 20 fps not 120 😅

#

120 i wish

west lotus
#

20 fps makes a bit more sense

#

So each particle has its own gravity it applies to other particles ?

hybrid cloud
#

yep

west lotus
#

Your gonna need some sort of acceleration structure

hybrid cloud
#

the system caches a list of all particle positions (and masses) with a grav field, then iterates over every particle that has a grav reciever component and modifies the velocity by iterating over the aforementioned list of particles and applying gravity for each

hybrid cloud
west lotus
#

Its something that will help you get only the closest particles to a given particle. Im thinking of what structure exactly would fit your case best

hybrid cloud
#

ahh i see

#

so it would slightly sacrifice accuracy?

west lotus
#

It wont sacrifice any accuracy it will simply help you skip calculations for far away particles without having to iterate over all of them

hybrid cloud
#

...what if i want the calculations for those far away particles though

#

like, a large cloud of particles should have a grav influence on a particle a few km out from it

fervent furnace
#

Google n body simulation

hybrid cloud
#

well, thats what im making

#

i know what an n-body simulation is

fervent furnace
#

Then read the paper on how people accelerate it by spacing partitioning

west lotus
#

So how are you doing grav calc now. For every particle get a particle calc distance calc grav ?

west lotus
hybrid cloud
#

is it acceptable to post a code snippet here or do i gotta pastebin it

fervent furnace
#

The Barnes–Hut simulation (named after Josh Barnes and Piet Hut) is an approximation algorithm for performing an n-body simulation. It is notable for having order O(n log n) compared to a direct-sum algorithm which would be O(n2).The simulation volume is usually divided up into cubic cells via an octree (in a three-dimensional space), so that on...

west lotus
#

Yes so thats what is called the naive approach. You are effectively O^2

hybrid cloud
#

im aware of that haha im learning as i go here

hybrid cloud
hybrid cloud
west lotus
hybrid cloud
#

thats the part im hung up on

#

maybe ill have multiple modes

#

performance and accuracy

fervent furnace
#

It must affect the accuracy but the result is always deterministic if your algorithm is deterministic

#

If you aim for accuracy then the only choice is n^2 algorithm

hybrid cloud
#

so the one i use right now?

#

i think what i might end up doing is having two seperate components and two seperate systems for accurate gravity and performant gravity

#

so the player could use a mix of the two if they wanted to

west lotus
#

Are you making a game or a scientific simulation where the accuracy of results actually matters

hybrid cloud
#

its a hobby project but you could say both

#

i just personally really like the idea of a perfectly accuarate simulation

#

if i can implement both its a win win

#

i'll just optimize it to whatever extent im able to

#

its not like 11k particles is anything to sneeze at

#

imo

west lotus
#

For a cpu nbody thats pretty decent

#

I mean you could get better results if you start sacrificing somethings. Like each particle being an entity is bound to have overhead

fervent furnace
#

Simulation actually introduce inaccuracy since it is not solving the equations directly but iterate until the system is stable

chilly surge
#

(On a side note, a perfect simulation is simply impossible, game dev or not; see chaos theory and 3 body problem)

fervent furnace
#

Btw it is completely up to you to have which algorithm, slightly inaccurate result but faster or accurate but slower
note that they are both deterministic

hybrid cloud
#

yeah thats kinda what i want to do

#

i know its not technically perfect

#

i just like the idea of having everything influencing everything else

fervent furnace
#

Game is more focusing on real time interaction, so why performance matter and you can have inaccuracy results

hybrid cloud
#

game will be mostly about setting up a simulation and watching it play out

#

so i like the idea of having both options

#

think universe sandbox

#

if you've ever seen that

#

setting up spawners, pausing mid sim to add/change stuff, etc

hybrid cloud
fervent furnace
#

I think you can allow the change of algorithm at the very beginning (i am not sure if you should allow the change while playing since the result can be non deterministic)

hybrid cloud
#

doesnt matter to me if it changes while playing thats up to the user

#

my idea is to have the algorithm used be set on a per-particle basis if possible

halcyon mirage
#

sorry for asking it here but in other group no one responding

#

i have been trying to make a playble ads, and i thought that i will do it with the help of WebGL build. but it is giving a lot of file and i need a single html file. now after spending a lot of time, i am thinking is it even possible to make a playble ad directly from unity/ webgl.

fallen topaz
#

hello, im quite new here
is there a more efficient way to keep a database of characters with their own specialty other than making a list of the parent character

like assuming a moba game, im keeping the characters alongside with their abilities

merry stream
#

so I made a procedural 2D TileMap, how can I add colliders to certain types of tiles?

hasty canopy
#

Although it's completely data structure related issue

fallen topaz
#

scriptable objects for the database right, pretty sure i cant just use polymorphism on a scriptable object that just collects data

#

was just having the problem to keep the abilites

hasty canopy
merry stream
fallen topaz
patent venture
#

Having trouble between choosing unity or unreal as an engine. Personally Id choose unity over unreal however most of the AAA industries hire developers experienced in C++ which makes me want to go for unreal, any suggestions on which one I should choose?

lean sail
hasty canopy
#

Use that, and give whatever shape you want/don't want

fallen topaz
hasty canopy
#

Removing physics shape for certain tile would make it so no collider for that tile

lean sail
fallen topaz
#

in database, yea tbf prefabs are the same as SO, but SOs are way better right..
Tbf i dont even know if there is a more efficient way, and the whole point is just to make it more efficient / save more space thats all

#

it works tho, totally just afraid of the impact for future progresses, cause im still new

hasty canopy
lean sail
#

what, how would this be any nicer to do with SO?

mild coyote
fallen topaz
#

in organizing things :/

lean sail
#

nope

#

not in this case

hasty canopy
fallen topaz
# lean sail not in this case

owh alright then, id suppose that there is no other way to resolve this so yea imma just continue, thanks tho for the help

#

thought i'd learn some things i dont know

lean sail
#

this is just silly

mild coyote
hasty canopy
lean sail
#

this is why i ask the use case, we are speculating at what they actually want to do

hasty canopy
lean sail
#

"dozens of 100 prefab"?

hasty canopy
lean sail
#

wat

hasty canopy
#

Nevermind

#

Anyone?

mild coyote
#

iirc, master/server need to broadcast the input from one client's input to other clients so other client can see the input

#

wait, that can't be right 🤔
it should be automatically synced

hasty canopy
upper pilot
#

Whats a good way to set EventSystem.firstSelectedGameObject to an object you want to be selected by default when you switch UI?
Do you add a class to all UI elements with "OnEnabled" that will set this value or do you use UI Manager to set this up for everyone when the UI changes?(Tho some data is added at runtime which still requires you to get that gameObject from other UI elements.)

mild coyote
lean sail
hasty canopy
#

In my logic
For sideways rotation entire body is turning sideways,
For up and down rotation only head is turning up and down

hasty canopy
upper pilot
#

Seems like EventSystem.current.firstSelectedGameObject is not the same as EventSystem.current.SetSelectedGameObject(GameObject gm);

#

First one actually sets the variable, but the second one does something behind the scenes.
Both works tho, but if I want to get currently selected game object I can only use 1st option?

#

there is currentSelectedGameObject

#

so I guess firstSelectedGameObject is only meant to be used once?

south violet
#

Any idea whats better to use for simple readonly data container?
record
or
readonly struct?

latent latch
#

I usually just use class because struct initializers are poopy

lean sail
#

depending on the use case scriptable objects might be good. SO is pretty much just supposed to be a immutable data container.

south violet
lean sail
#

like if you want this to be data made during editor time

viscid kite
#

is there a way to detect if you came in contact with the top of a surface instead of say the side or the bottom?

lean sail
#

compare it to Vector3.up to see how close it is to up

hybrid cloud
#

thank you, github copilot :(

#

thats better

strong night
#

Hey there! I'm having some troubles with json deserialization (who doesn't lol)
I have this json:

{
  "uuid": "4fe0f2eb-9b83-4d77-ae9a-2ad45337b20c",
  "name": "Small Chest",
  "sprite": "chest_0",
  "sizing": {
    "x": 1,
    "y": 1
  },
  "scripts": [
    {
      "name": "Storage",
      "props": {
        "space": 15
      }
    }
  ]
}

and my classes are:

[Serializable]
    public class Sizing
    {
        public int x;
        public int y;
    }

    
    [Serializable]
    public class Scripts
    {
        public string name;
        
        
        public Dictionary<string, object> props;
    }
    
    [Serializable]
    public class ItemDefinition
    {
        public string uuid;
        public string name;
        public string sprite;
        public Sizing sizing;
        public Scripts[] scripts;

    }

Yet, the props always comes as null

#

I do need the props attribute to be some kind of generic though as it'll be handled by the scripts themselves

mellow sigil
#

What do you use to deserialize it?

strong night
#

JsonUtility.FromJson<ItemDefinition>

mellow sigil
#

JsonUtility doesn't support dictionaries

strong night
#

Is there any other tool that does? Or any alternative? I tried making it a simple object but won't work

mellow sigil
#

Well practically all other JSON libraries do. Newtonsoft or System.Text.Json for example

strong night
#

Any you'd recommend? (I'm not a c# guy so happy with tips!)

clear oriole
#
private void CheckGroundSlope()
    {
        Ray ray = new Ray(transform.position, -transform.up);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, groundCheckDistance, groundLayer))
        {
            Quaternion targetRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);

            targetRotation *= Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0);

            playerVerticalRotation = targetRotation.eulerAngles;
        }
    }

    private void RotatePlayer()
    {
        Vector3 movementDirection = PlayerInputManager.Instance.UpdateMovementInput().normalized;

        if (movementDirection != Vector3.zero)
        {
            Quaternion targetRotation = Quaternion.LookRotation(new Vector3(movementDirection.x, 0, movementDirection.y), Vector3.up);
            transform.localRotation = Quaternion.Slerp(transform.localRotation, targetRotation, playerRotationSpeed * Time.deltaTime);
        }

        Quaternion targetVerticalRotation = Quaternion.Euler(new Vector3(playerVerticalRotation.x, transform.rotation.eulerAngles.y, playerVerticalRotation.z));
        transform.rotation = Quaternion.Slerp(transform.rotation, targetVerticalRotation, playerRotationSpeed * Time.deltaTime);
    }

So im running into a slight issue and im trying to figure out why my player only rotates about half way while moving but when i stop then it completely matches the angle of the object im on. I can get a video of it if need be.

#

also is that block to bug

#

big

mellow sigil
#

System.Text.Json is the C# built-in one, that's what I use

strong night
#

Sweet, I'll use that then

#

Thanks!

#

Hmm, but how do I integrate System.Text.Json in unity? It doesn't seem to exist

mellow sigil
deft timber
#

playerRotationSpeed * Time.deltaTime - ❌

clear oriole
deft timber
#

the solution is to lerp properly

#

last lerp/slerp parameter is the interpolation point between start and end point

#

from 0 to 1

#

where 0.5 is in the middle between start and end

#

0 is start, 1 is end point

blazing smelt
#

So RectTransformUtility.ScreenPointToLocalPointInRectangle() returns true 'if the plane of the RectTransform is hit, regardless of whether the point is inside the rectangle'. What constitutes hitting versus missing? Because sometimes this function will just randomly return false, even though it's running repeatedly with the exact same input values.

quartz folio
#

Ie. it's visible as a line, and the ray doesn't intersect the plane

blazing smelt
#

The rectttransform is attached to an overlay canvas, so I set the camera value to null as specified in the documentation

#

"The cam parameter should be the camera associated with the screen point. For a RectTransform in a Canvas set to Screen Space - Overlay mode, the cam parameter should be null."

quartz folio
#

Yes, that's what you should be doing

#

I cannot tell you why it would return false unless your transform is rotated

#

The code is not private, you can see how it works

blazing smelt
#

oh shit

#

the overlay canvas is a child of the player character, that rotates around because it's an FPS

quartz folio
#

it probably should not be set up like that

hybrid relic
#

if thats an asset thats worth reporting to the creator

blazing smelt
#

I'll write it down and sort it out some other time

hybrid relic
#

then report it to yourself ^^

quartz folio
#

reading the code, that would seem to be the case

blazing smelt
#

because I'm real tired

#

I tried just changing the screen space to camera and it caused some other issues

#

thanks @quartz folio @hybrid relic

chilly surge
hybrid relic
wide quest
#

So I just updated VS to the latest version, I put this code in and comes up with this error. How can I update this so that the code works fine?

somber nacelle
#

the c# version is typically dependent on your unity version. what version of unity are you using

knotty sun
wide quest
#

im not using unity atm, Im only using vs, im doing a text based game

somber nacelle
#

this is a unity server, mate

wide quest
#

should hopefully be the easiest thing to start off with, right?

#

well, isn't vs part of making games?

somber nacelle
#

you can ask your non-unity related c# questions in the !cs discord

tawny elkBOT
wide quest
#

isn't that what --- nvm I guess I'll ask there then

#

thanks anyways

somber nacelle
knotty sun
wide quest
somber nacelle
#

you could have also just as easily (if not more easily) googled it. which should be the first step before asking here anyway

knotty sun
chilly surge
#

The C# server has commands like $helloworld, if you are new to C# in general it's definitely a good place to start.

wide quest
#

wow 😒 getting quite the ||hate|| vibe here...

somber nacelle
#

"i intentionally ignored the off topic rules and the context of where i asked a question and got pissy when i was told to ask it in the right place or actually put effort into finding the answer myself with a 2 second google search, but everyone else sucks"

wide quest
#

Fine I guess I wans't able to get the help I thought I could. I guess I'll just leave the server then.

#

bye

chilly surge
#

To explain why people are directing you to the C# server rather than here, the reason is that your question is about project setup, and Unity project setup is very different from a regular C# project setup.

knotty sun
somber nacelle
#

they already left lmao

knotty sun
#

over-entitled little children

swift falcon
#

@everyone

#

guys how do I comunicate from isystem to monobehaviour unity

#

in unity dots

#

@everyone

somber nacelle
# swift falcon @everyone

that is obviously not going to work. and what did you expect, to ping 80000 people just to get help?

swift falcon
#

@here

somber nacelle
knotty sun
swift falcon
#

you 9 yo

somber nacelle
#

why are you literally trying to spam and annoy people? are you 9?

quartz folio
swift falcon
quartz folio
#

Then don't cross-post.

swift falcon
swift falcon
#

bro I can't type a single damn question in this server

quartz folio
#

!warn 812745620308885504 don't spam, cross-post, or be an antagonistic git

tawny elkBOT
#

dynoSuccess m7md399 has been warned.

swift falcon
#

male karen

quartz folio
#

!mute 812745620308885504 1d when you return, clean up your shitty behaviour or you will be removed completely

tawny elkBOT
#

dynoSuccess m7md399 was muted.

tropic surge
#

You are v kind not to instaban 😄

quartz folio
#

One of my many regrets

vagrant blade
#

There's still time!

#

Imagine being so arrogant to think everyone would want to assist you with your issue.

quartz folio
#

!ban save 812745620308885504 on second thought, your attitude and behaviour is intolerable. Bye.

tawny elkBOT
#

dynoSuccess m7md399 was banned.

round violet
#

🫡

quartz folio
#

Thanks for the second opinions

knotty sun
#

Hmm, Community Moderators posting off-topic, whatever will we see next?

dawn nebula
#

Man comes in asking a question. Attempts to spam ping everyone. Resorts to insults when told not to try to ping everyone.

#

Advanced

lunar python
#

Hello, I am encountering a problem which seems to be with float's precision when the number is too small when multiplied with Time.deltaTime causing the error to accumulate throughout the frame, making the healthBar changing too fast (i.e. I set it to take about 3 seconds to make the slider slowly change its value but it's taking much less time). I am thinking of using double but Mathf.Lerp dont seem to support double.
Anyone have an idea of what's else is wrong with the function? Thanks
https://paste.ofcode.org/dh65Afs7742KmaJvSbHtki

rain oasis
#

Hey guys, how do I debug this?

somber nacelle
#

that's an editor bug likely due to having the Animator or Shader Graph window open. you can typically ignore it or just restart the editor if it persists

rain oasis
#

I hope so, kinda annoying

#

What about this? Is it because I use too much Invoke??

somber nacelle
somber nacelle
rain oasis
#

zero Job

fervent furnace
#

after 100 10^7 seconds were pass my progess bar reach 1

lunar python
#

okay thanks I will try that

somber nacelle
#

@simple lynx if you need help with something then ask it here. do not send unsolicited DMs or friend requests

simple lynx
#

Your so arrogant

#

Unsolicited DMs lmao

somber nacelle
#

it's clear you are trying to get help with something via DM since you previously told someone else to check their DMs before you sent an unsolicited friend request to me. it is against server rules to send unsolicited DMs #📖┃code-of-conduct

somber nacelle
simple lynx
#

Mr. Karen

lunar python
#

btw how does lerp differs from normal IEnumerator method or I am getting it wrong

somber nacelle
#

those are completely different concepts. lerp is just math

leaden ice
lunar python
#

oh I thought it slowly interpolate

somber nacelle
#

you would typically be lerping over time, but that doesn't mean it has anything to do with coroutines. you can lerp in a coroutine or in update or really anywhere

heady iris
#

That's it

cobalt jackal
#

Hey, is here anyone who has experience with Wheelcolliders? And can tell me why I cant accelerate my object (bike) past about 2m/s despite cranking torque?

heady iris
#

perhaps the wheels are slipping

cobalt jackal
sleek bough
#

!warn 441242287960227842 Don't send unsolicited DMs or friend requests, don't spam the channel or insult members. Last warning on that account.

tawny elkBOT
#

dynoSuccess pixiejohn has been warned.

warm lava
#

Who know how to solve the problems \

somber nacelle
#

always start with the top error in the console

heady iris
#

The later errors are just Unity complaining that there were errors, yeah.

warm lava
#

so how do I do

somber nacelle
#

start by looking at the first error in the console rather than the last one . . .
it also doesn't even look like a code issue

warm lava
#

ok

#

I can’t solve it

muted sable
#

It tells you what line the exception is on

somber nacelle
#

well it's still not a code issue. it's probably related to special characters in the path, but that's a guess 🤷‍♂️

leaden ice
deft timber
muted sable
#

Also mentions backend exited with error code 2. Did you look up what that means?

warm lava
hybrid relic
hybrid relic
somber nacelle
#

or it's just an editor bug that will randomly happen. this happens pretty often in many of my projects, especially if i've not restarted the editor in a long while

warm lava
somber nacelle
#

that wasn't even a reply to you, mate

hybrid relic
warm lava
#

I change file name but it didn’t work

heady iris
#

but it wasn't this problem

#

it was an error with code signing

#

ah, and this is an iOS build, not a macOS build

#

so I don't have any experience there, unfortunately

warm lava
#

Do the vscode file name and project name have to be the same?

#

It can run at macOS but When Compiling at iOS It show me Error

warm lava
rigid island
#

yeah your project path , maybe IL2CPP doesn't like that

warm lava
#

What you mean ?

rigid island
hard viper
#

lots of software hates dealing with filenames that contains a space key because space usually gets parsed as separating different commands or inputs.

#

Underscores or hyphens are the normal workarounds

#

I’m honestly surprised modern operating systems don’t automatically stop you from entering spacebar into filenames

fringe ridge
#

I need to know if mouse is over any UI elements to stop some calculations happening based on mouse collision. Any efficient ways to do that, since i'm doing it in Update

knotty sun
fringe ridge
#

do they?

jade vault
#

As a game developer who has released titles before, I've discovered a way to detect piracy using most Steam Emulators. However, any piracy DRM can be bypassed, especially since Unity is so open to decompilation techniques.

I found that most SteamEmulators, will fake a Steam User, and the "persona" name. By using this, you can detect piracy by having a check for the players name on the SteamManager initializing. Using Steamworks.NET, the most common plugin, you can just check if lets say, the username text box did not change, and the manager did not initalize. This is a simple attempt to catch pirates on lets say first week of a successful release.

In my case, I am just making an image appear over the title screen if detected.

If anyone who wants a very simple easy way to detect piracy, this is one way!

It is very easily bypassable, and will be, but if people are lazy with their pirating, its a good way to catch someone on an illegal copy of your game. I used this in a past title of mine, which changed the characters material. I caught a lot of people pirating my game this way, and well theres not much you can do after that, but you can leave a nice comment on their lets play xD

    void Start()
    {
        if(SteamManager.Initialized)
            username.text = SteamFriends.GetPersonaName();
        StartCoroutine(CheckForPiracy());
    }

    IEnumerator CheckForPiracy()
    {
        yield return new WaitForSeconds(0.5f);
        if (SteamManager.Initialized)
            username.text = SteamFriends.GetPersonaName();
        yield return new WaitForSeconds(0.1f);
            if (username.text == "PIRATE")
            {
                piracy.SetActive(true);
            }
    }```

Simple, works. Its by no means secure, but, best piracy avoidance is if someone can easily pirate your game, there's no reason to "crack" your game. This may be common knowledge but I did want to share it.
fringe ridge
#

thats not even for global, it's just for the game object

hard viper
#

what

#

just implement the IPointerEnterHandler etc interface on a monobehaviour on the object in the UI, and it will invoke the relevant method when the pointer enters it

jade vault
#

legit copy compared to a pirated copy

fringe ridge
#

attaching a script to all of them seems very inefficient for such a simple thing

hard viper
#

oh okay then. that changes everything

deft timber
hard viper
#

ok so here is what you do.

#

make a monobehaviour, have it implement IPointerEnterHandler, and make the function you want to call tied to the relevant interface function

knotty sun
jade vault
#

Yeah like I said, it is. However big names in the space, like IGG games, DID NOT bypass it. If the game can be played by a steam emulator, most of the time they do not go to the lengths to bypass something like the Steam Persona name not being set

#

A way I personally went about detecting piracy of my game(s), just wanted to share.

fringe ridge
#

nahh, im not doing that. My ui lets me to just cut away 10-15% of the screen and that's it. I can just tie it to a boolean that knows if cursor can be used for gameplay or not.

#

Im sure it's not huge, but checking a list of gameobjects every frame just to know if i can use the mouse or not is kinda inefficient. If I needed to know this outside of Update, then sure

hard viper
#

Ok, so you are telling me you want to invoke a function whenever a pointer enters a given object, but do not want to use the feature to invoke a function when a pointer enters an object?

fringe ridge
#

sorry, i dont get what you mean 😄 I need to know if my mouse is over a certain part of the screen (or over any ui objects) every single frame. I dont want to attach scripts to every object or check the list of gameobjects the mouse is over every single frame

deft timber
#

set a bool to true in pointer enter

#

and to false on pointer exit

#

you dont need to check if every single frame

hard viper
deft timber
#

it will

hard viper
#

it’s too easy

deft timber
#

ah okay haha

#

didint get it 😄

hard viper
hard viper
#

now you can do this only when the pointer actually enters something relevant, or you can do it on every frame, but either way, you will have to do it.

#

the computer isn’t magic. it just does what you tell it to

fringe ridge
#

OnPointEnter doesnt even get called when pointer interacts with any object that doesnt implement the interface

deft timber
#

obviously

hard viper
#

that’s the point, isn’t it?

fringe ridge
#

there are way more efficient solutions just doing some simple math instead of having these interfaces implemented

deft timber
#

then do your maths

hard viper
#

then do it

fringe ridge
#

thats why im asking if there is just a simple global variable somewhere that holds stuff like this

#

already

deft timber
#

EventSystem.IsPointerOverGameObject

fringe ridge
#

event handler has that stuff i think on gameplay

deft timber
#
  // Check if the mouse is over a UI element
  if (EventSystem.current.IsPointerOverGameObject())
  {
      Debug.Log("mouse over UI");
  }
fringe ridge
#

Thank you

sage latch
#

2018 docs 🫠 (though i dont think it has changed)

deft timber
#

1 minute of googling

fringe ridge
#

didnt find it when i googled :D, nevermind, thanks.

#

that's what i needed

deft timber
#

literally first link

fringe ridge
#

that's what i did

deft timber
#

this link in the OP post lol

#

literally what i gave you

#

googling is a skill you need to learn ig

trim schooner
#

Searching the internet is a devs #1 skill

knotty sun
deft timber
#

what would reading error message give you

#

if you cannot google it

trim schooner
#

lots of messages give instructions on what to do

knotty sun
#

read first, google second

deft timber
#

think first, read second, google third

trim schooner
knotty sun
#

think? nah asking waaay too much

deft timber
#

way easier

jade vault
#

Lmao

knotty sun
#

indeed

#

'dont work, how fix'

jade vault
#

caveman style

trim schooner
#

As a game developer who has released

eager steppe
#

Might be overthinking this, but I want to make this Timeline feature in my game's level editor work a bit like the Unity Animation Pane.

There's two parts to this of course, the line that goes across the timeline so that it catches keyframes and does the shit that the keyframe has info far, and the actual length of the lines themselves.

I'm unfortunately very new to level editors and how they work, so I'm not actually sure what to type into Google to get a good result, nor what to do with my math skills, especially considering I'm using recttransform like a nerd for my UI instead of sprites

#

in other words, "don't work, how fix?"

rigid island
woven veldt
#

Can someone briefly explain to me or give me resources that explain how the convert to entity script works for gameobjects and how to impliment it properly

knotty sun
eager steppe
#

wow i can't even say uh 😭

jade vault
#

How do you guys organize your scenes? Do you use any tools to make your hierarchy neat?

knotty sun
#

in a word, no. Why would I want to clutter up my build with a bunch of extraneous gameobjects taking up valuable resources?

vivid heart
#

What is your opinion about this class? Can you suggest any improvements or automation?

using CodeBase.GameLoading.States;
using CodeBase.Infrastructure.States;
using CodeBase.Services.LogService;
using UnityEngine;
using Zenject;

namespace CodeBase.GameLoading
{
    public class GameLoadingSceneBootstraper : IInitializable
    {
        private readonly SceneStateMachine sceneStateMachine;
        private readonly StatesFactory statesFactory;
        private readonly ILogService log;

        public GameLoadingSceneBootstraper(SceneStateMachine sceneStateMachine, StatesFactory statesFactory, ILogService log)
        {
            this.sceneStateMachine = sceneStateMachine;
            this.statesFactory = statesFactory;
            this.log = log;
        }

        public void Initialize()
        {
            log.Log("Start loading scene bootstraping");

            sceneStateMachine.RegisterState(statesFactory.Create<ServerConnectState>());
            sceneStateMachine.RegisterState(statesFactory.Create<LoadPlayerProgressState>());
            sceneStateMachine.RegisterState(statesFactory.Create<PrivatePolicyState>());
            sceneStateMachine.RegisterState(statesFactory.Create<GDPRState>());
            sceneStateMachine.RegisterState(statesFactory.Create<FinishGameLoadingState>());

            log.Log("Finish loading scene bootstraping");
            
            // go to the first scene state
            sceneStateMachine.Enter<ServerConnectState>();
        }
    }
}
jade vault
knotty sun
jade vault
#

I've never noticed a performance difference with empty game objects just sorting an hierarchy

#

I mean Im sure maybe if I instantiated 10000 of them, then def.

wide dock
jade vault
#

Ah okay, will do

#

Thanks

knotty sun
swift trench
#

Checkout my new Kickstarter campaign.

knotty sun
#

this is not the channel for this

swift trench
#

What is

knotty sun
jade vault
#

this is just a polygon space pack too

vivid heart
trim schooner
knotty sun
vivid heart
knotty sun
#

too much happening of which 'I know nothing'

#

I would worry about the use of CodeBase as a namespace though

vivid heart
knotty sun
#

even more reason to make it something less generic

vivid heart
knotty sun
#

So the future you does not hit namespace conflicts

#

also
statesFactory.Create<>().
I would use or at least make an override
statesFactory.Create(Type type);
then the types become soft rather than hard as you now have, a bit of future proofing

#

Also CodeBase in no way explains what is going on

vivid heart
# knotty sun also statesFactory.Create<>(). I would use or at least make an override statesFa...

I made a little mistake, but an interesting one :))

public void InstallStates<TBaseState>(StateMachine<TBaseStates> machine) where TBaseState : IExitableState
{
    var derivedStateTypes = AppDomain.CurrentDomain.GetAssemblies()
        .SelectMany(assembly => assembly.GetTypes())
        .Where(type => typeof(TBaseState).IsAssignableFrom(type) && type.IsInterface && type.IsAbstract)
        .ToArray();

    foreach (var stateType in derivedStateTypes)
    {
        var state = instantiator.Instantiate(stateType);
        var castedState = state as ExitableState;
        machine.RegisterState(castedState);
    }
}
limber wharf
#

hey guys, I am using Unity 2022.2.0f and I have a class which I create a list from, however, when I change window or press play and stop some of the elements just make it's content "disappear", I'll send the class and also pictures of what's wrong

somber nacelle
#

show the !code where you're actually using this class

tawny elkBOT
limber wharf
#

it changes from this

#

to this

somber nacelle
#

okay and keep in mind that changes made during play mode do not persist when exiting play mode

limber wharf
#

yeah ik

somber nacelle
#

well there's nothing in there that would cause it to just randomly remove items from the list(s) except for your UpdateCosmeticsInside method. however it is also public so anything with a reference to the Chests component can change it

limber wharf
#

no, look closely to the picture, it's not removing items, it does not render it's content

somber nacelle
#

that would probably be more obvious if you didn't crop the screenshots so much. all i see is the Cosmetic Index list in the second one and it just has fewer elements than the first screenshot

limber wharf
#

the first picture it shows Cosmetic Index -> Element 0 - > Cosmetic Index -> Element 0 = 2
and in second it's just Cosmetic Index -> Element 0 = 2

#

I'll post it again less cropped

somber nacelle
limber wharf
limber wharf
#

so what do you think?

somber nacelle
#

no idea, seems like an issue with the editor not your code 🤷‍♂️

#

if you have a custom inspector or something that would potentially break it, but you'd ask for help with custom inspector stuff in #↕️┃editor-extensions

limber wharf
#

no custom inspector

#

broo, I don't want to go to higher Unity version

#

do you think there is any other way I could make this without using the class?

#

maybe I can assign it's values in the code

#

it's not much effective but it could work

zenith estuary
#

is there a reason it is fine making a 100x100 and a 200x200 but can't make a 300x300, its probably very simple but I can't find it

simple egret
zenith estuary
simple egret
#

On the Mesh you create in code yes

zenith estuary
#

ok

#

ye it worked ty

viscid kite
#

so i want my character to walk down a slope without constantly falling as it goes down with this code. Is there a good way to do so? (_direction variable takes the player input on keyboard or controller and makes a vector based on x and z leaving y usually at 0)

void Move()
    {
        if (_direction.magnitude >= 0.1f && _canMove)
        {
            _anim.SetBool("isMoving",true);// Transition to move state

            // Determine angle to be facing based on camera direction and input direction
            _targetAngle = Mathf.Atan2(_direction.x,_direction.z) * Mathf.Rad2Deg + _camera.eulerAngles.y;
            _angle = Mathf.SmoothDampAngle(transform.eulerAngles.y,_targetAngle,ref _turnSmoothVelocity, turnSmoothTime);
            
            // Generate move direction using character's current forward
            _moveDirection = Quaternion.Euler(0f,_targetAngle,0f) * Vector3.forward;

            // Move based on rigid body and movement speed and rotate them accordingly
            _rigid.MovePosition(transform.position + (_moveDirection.normalized * Time.deltaTime * _baseMoveSpeed));
            transform.rotation = Quaternion.Euler(0f,_angle,0f);
        }
        else
        {
            // Transition out of movement if movement input is less than 0.1 or if the player can't move
            _anim.SetBool("isMoving",false);
        }
    }
hard viper
viscid kite
hard viper
#

that is going to be rough. Have you considered KCC?

viscid kite
#

KCC?

hard viper
#

kinematic character controller is a free asset, with a physics solver, that let you move a kinematic rigidbody around while respecting slopes, stairs, walls, etc

viscid kite
#

guess i'll give a try

hard viper
#

look closely at what it does first. It takes effort to implement

#

it’s more like a separate API from rigidbody

lean sail
somber nacelle
hard viper
#

KCC solves the basics of simple motion in 3D with slopes and stairs. i recommend you check it closely before deciding what you want

#

dynamic RBs always have to fight forces and the physics system. They inherently do NOT follow simple commands, like move along a slope.

lean sail
#

KCC is a bit bulky tbf. It would take them quite some time to go through it to even decide if its fit for them

next salmon
#

hey guys, im using a premade package called kinematic charachter controller to set up my player controller and im facing some issues.
as you can see the Y rotation of the player is not acting like how it should.
any ideas where the issue is? im guessing it has something to do with the ProjectOnPlane things in the code snippet down below but i cant figure it out.

code snippet related to setting the player rotation:

//Calculate camera direction and rotation on the character plane
            Vector3 cameraPlanarDirection = Vector3.ProjectOnPlane(targetCamRot * Vector3.forward, Motor.CharacterUp).normalized;
            if (cameraPlanarDirection.sqrMagnitude == 0f)
            {
                cameraPlanarDirection = Vector3.ProjectOnPlane(targetCamRot * Vector3.up, Motor.CharacterUp).normalized;
            }
            Quaternion cameraPlanarRotation = Quaternion.LookRotation(cameraPlanarDirection, Motor.CharacterUp);

            if (cameraPlanarDirection.sqrMagnitude == 0f)
            {
                cameraPlanarDirection = Vector3.ProjectOnPlane(targetCamRot * Vector3.up, Motor.CharacterUp).normalized;
            }

            _moveInputVector.x = (cameraPlanarRotation * moveInput).x;
            _moveInputVector.z = (cameraPlanarRotation * moveInput).y;
            _lookInputVector = cameraPlanarDirection;
#

this is where i set the targetCamRot used in the first code snippet

            // NOTE : Do NOT Use time.Deltatime, beacuse the mouse input that is coming from the new input system is already a delta. more info : 
            https://unity.huh.how/programming/input/built-in-input/mouse-delta-time
            // Rotate the camera based on mouse input
            float mouseX = lookInput.x * sensitivity;
            float mouseY = lookInput.y * sensitivity;
            //we use the lookInput values to rotate the camera horizontally and vertically using the transform.Rotate() and Quaternion.Euler() functions 
            //respectively.
            rotation.x -= mouseY;
            rotation.x = Mathf.Clamp(rotation.x, -90f, 90f);

            rotation.y += mouseX;

            camHolder.transform.localRotation = Quaternion.Euler(rotation.x, 0f, 0f);
            Character.targetCamRot = rotation.y;
hard viper
#

speak of the devil lmao

#

also

#

!code

tawny elkBOT
next salmon
# hard viper !code

well i mean im not sharing an entire script and only short code snippets so i dont see why that would be necessary

#

the _lookInputVector is the exact code from kcc, but it dosnt work in this situation

viscid kite
#

i guess i should probably modify it somewhere there in the move script

#

cause right now i just have it where it replaces the original move vector from the player input with that

sudden vapor
#

why does gravity not work when my player animation is playing

viscid kite
#

that said yeah it is dynamic, should i change it to kinematic then?

#

at least when grounded?

somber nacelle
#

kinematic bodies are not affected by forces like gravity so you'd have to add your own if you make it kinematic

viscid kite
#

so for the project on plane thing like you suggested

#

would it still work if it's dynamic

#

or does it need to be kinematic?

somber nacelle
#

yes because it has nothing to do with the rigidbody

viscid kite
#

ok so for the projectedonplane where should i slot that?

#

like in the code block i showed above

#

the _direction gets replaced with that vector

#

if i'm on a slope ( i have a slope check using raycast and angle difference checking)

somber nacelle
#

get the normal of the surface. then pass your move direction through Vector3.ProjectOnPlane with the surface normal. that is now the direction of your movement

hard viper
heady iris
#

your code blocks are just on the borderline where I'd want to use a paste site

#

The lines are very loooong

#

which makes it worse on mobile

hard viper
#

if I need to scroll through 2 screens on mobile, it’s too long

#

this is a discord, not a github

viscid kite
#
public Vector3 GetSlopeMoveDirection(Vector3 direction)
    {
        return Vector3.ProjectOnPlane(direction,hit.normal).normalized;
    }
somber nacelle
#

you have now shown multiple disjointed methods, most of which i have no context for the order they are called in.
however i can say that if you are only projecting it there, then you aren't doing it at the right time because you only do it when the input changes. not when the the ground normal changes

viscid kite
#

oh ok

lean sail
#

You want to project your movement onto the floor. For input you only need to change it so that it is relative to where the camera is looking

viscid kite
somber nacelle
#

call it when you need to get the direction to apply your movement

viscid kite
#

so would that be when the script receives movement input?

somber nacelle
viscid kite
#

ohhhh ok let me do that then

#

so not pre-emptively like i did earlier

#

pre-emptively meaning doing it directly from the input before any calculations like angle to move at

somber nacelle
#

correct because as your object moves the surface it moves along may change. you can't just precalculate the surface normal and keep reusing it, you need to get the current normal or you run into the issue you are having

viscid kite
#

eye sea

#

it works

#

mostly (it's gonna be additional issues i'll need to tackle)

#

basically just being when i hit the end of a slop where it goes back to being flat (so normal facing upward), my character briefly for a moment enters the falling state before going back to ground

#

but i think it just has to do with some of my other code earlier for fall checking

#

still tysm @somber nacelle

woven veldt
#

Hello peeps. I have this conveyor belt prefab and I want to put a shader on the part that moves. Is there a way to do this without having two separate objects and only have 1 mesh or not

leaden ice
#

of course - just UV map it properly

#

and/or use two submeshes

tropic totem
#

hey guys
Had anyone watched and followed this video ?

#

The Shoot() function
Idk why it was only called once @@

woven veldt
#

Sorry another question. I need lots of objects to be animated. Should I be using hybrid rendering for this where I have a game object that recieves rendering info from ECS?

golden garnet
#

How do I tell if a gameObject collided with a child of another gameObject?

#

I'm trying to have the parent gameObject be told when another object collides with its child

#

without adding another script on that child that tells the parent when something collides with it

rigid island
golden garnet
half saddle
#

I can not for the life of me figure out how to get a touch release working with Unity's Input System and input actions assets. Could anyone familiar with this system help me out?

#

This is what I have tried.

#

But, the event is triggered for the press and release of touch.

cosmic rain
tawny elm
#

i have a VideoPlayer component, but its instantiated from a prefab.
once instantiated, it cant find the main camera, its videoplayer.camera property just appears blank.
the property is read only, so i cant assign it through code.
the only way i can find to assign it is through the inspector, but i cant because its instantiated from a prefab.

#

the whole of google is giving me nothing so this is my last resort right now

#

as far as i can tell, unity just never considered this situation so its impossible

cosmic rain
#

The docs don't mention anything about it being read-only.

tawny elm
sharp agate
#

Why we use Time.deltaTime? i'm new

tawny elm
#

Property or indexer 'Component.camera' cannot be assigned to -- it is read only

tawny elm
sharp agate
#

i understand

#

thanks

terse turtle
#

How can I efficienlty switch the turret stats with cases? I just want it to be more clearer without having to have alot of code visible/make a bunch of functions. ```cs
void ManageTurretType() {
switch (currentType) {

        case 0: // Change turret stats to Light Turret stats
                break;
            case 1:// Change turret stats to Heavy Turret stats
                   break;
        default: // Change turret stats to Default Turret stats
            break;

    }
}```
#

I understand I can just say: turretHp = LightTurret.hp, turretDMG = lightTurret.DMG etc

cosmic rain
#

I recommend checking the docs every time you have issues with the API.

minor hazel
#

I have a 2D game i’m working on and an entity in the game needs to get to an object but there are obstacles in the way that they need to avoid. So far i’ve just had them moving directly towards the transform but now I need to get around these obstacles. Does anyone have an idea on what i could use to do this?

cosmic rain
terse turtle
wide dock
cosmic rain
terse turtle
wide dock
#

basically what dlich also just said

cosmic rain
#

I'd use SOs for them.

#

Not sure what that emoji is supposed to represent. If you don't k ow what SOs are, they're ScriptableObjects

terse turtle
#

I am very much lost. I don't understand what you are telling me about the stats

cosmic rain
cosmic rain
terse turtle
terse turtle
cosmic rain
#

The array you could initialize from the inspector.

cosmic rain
terse turtle
lean sail
#

🤔 do you know what an array is

terse turtle
cosmic rain
#

Ideally,

public class TurretStats : ScriptableObject
{}
#

But a serializable plain class is fine too I guess.

terse turtle
#

Wait, how is statsArray TurretStats[]? I can't find how you can make a class an array. Is it a int inside that class?

cosmic rain
#

Its an array of a type. Same as you can have an array of any other class...notlikethis

#

Did you never have a SomeClass[] field in your code?

terse turtle
cosmic rain
#

How about int[]?

terse turtle
cosmic rain
#

Well, it's basically the same.

#

The only difference being int is a value type and class is a reference type.

wide dock
#

I believe going through a C# course first would be preferable here

minor hazel
wide dock
#

A* pathfinding is probably the most well known one

terse turtle
#

Is there a way to just make a float function that takes in a class? Then just change that class to Light, Dark, or Heavy?

cosmic rain
#

A function that returns float?

#

Sure, but it's arguably worse than what I suggested.

#

Since you're gonna have a class of stats anyway.

#

It's kind a doing more work for nothing.

minor hazel
terse turtle
cosmic rain
#

Also, if I feel like you're clearly missing the basics of C#, I might not be able to help until you go through the basics.

terse turtle
cosmic rain
#

Not "basics on classes". Classes are one of the basic concepts of C# and OOP languages in general, so you should go over "C# programming basics".

lunar python
#

anyone knows how to make a group of serializablefield in the inspector colllapsible without having to making another public class and making it [System.Serializable]

tawny elm
cosmic rain
tawny elm
#

That's my fault for being blind tho

#

Just I did check the docs I'm not stoopid

hidden flicker
#

I made an abstract class called "Attack", and in another abstract class created an array of Attack scripts. But in the editor, I'm completely unable to add any Attack script objects to this array

quaint rock
#

so everything is abstract classes, you need to have a regular concret class extending a abstract class to use it for anything but referencing

hidden flicker
#

Yes, this is EXTREMELY confusing lmao

quaint rock
#

then it should work

#

should be able to reference PumpShoot in the Attack[]

#

PumpShoot will just need to be added as a component to a gameobject

hidden flicker
#

That was the issue

#

Ty

long scarab
#

hey there, I'm building a 3D tower defense and I've hit a wall with how I would store wave spawn data. I have a LevelManager that holds references to SpawnPoint prefabs that act as factories that LevelManager passes spawn info into. the issue I'm having is figuring out how to hold the data in a scriptableObject in a way that LevelManager would know what enemies are being spawned, at which SpawnPoint they are being spawned at, and the enemy ID for the SpawnPoint to pull a reference to the enemy prefab

latent latch
#

So, my LevelSOs contain multiple WaveSOs

long scarab
latent latch
#

Actually what I do is weighted spawns, so I give me WaveSOs enemy types and a weight modifier, so when it spawns an enemy it first picks from the random pool of assigned enemies (20% chance to spawn a skeleton, 80% for bats for that specific wave). For frequency it's normalized from the max time of the wave and distributed evenly, but I do have some slight deviations I can enable.

long scarab
#

ohh i see

latent latch
#

I still need to improve on it, but that's my base idea of it all

long scarab
#

so you have one overarching timer over the course of the entire wave and enemies are just spawned in at set intervals on that timer based on their type?

latent latch
#

Yeah, but it's not always just single enemies at a time, I have settings for making waves into formations that spawn a number of enemies at once

#

so like 20 formations in a span of 60 seconds, with respect to the max enemies that can be alive

long scarab
#

gotcha

latent latch
#

If I didn't want to use a weighted pool, I've also made the option to separate the groups of enemies with their own count, which then both will run its course over the time limit

ashen jasper
#

Does anyone know how to mirror armature based on the direction are on

#

this is my issue

#

I got sonic here with a perfectly normal animation facing the right direction

#

now here goes the issue. If you turn left he has his back turned

#

wait shit this is not animations my b

mild coyote