#archived-code-general

1 messages · Page 438 of 1

lilac frigate
#

this is so weird

So i added debug logs for main menu scene loading

UnityEngine.Debug:Log (object)
ClientNetworkManager:LoadMainMenu () (at Assets/Scripts/Client/ClientNetworkManager.cs:281)
ClientNetworkManager/<Start>d__7:MoveNext () (at Assets/Scripts/Client/ClientNetworkManager.cs:42)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetResult ()
ClientNetworkManager/<ProcessSteamPlayerInfo>d__15:MoveNext () (at Assets/Scripts/Client/ClientNetworkManager.cs:261)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Game.Model.Player>:SetResult (Game.Model.Player)
GameServices.PlayerService/<GetPlayer>d__1:MoveNext () (at Assets/Scripts/Shared/GameServices/PlayerService.cs:39)
UnityEngine.Awaitable:RunContinuation ()```

but then i get this null error


```NullReferenceException: Object reference not set to an instance of an object
ClientNetworkManager.LoadMainMenu () (at Assets/Scripts/Client/ClientNetworkManager.cs:283)
ClientNetworkManager.Start () (at Assets/Scripts/Client/ClientNetworkManager.cs:42)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) (at <314938d17f3848e8ac683e11b27f62ee>:0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at <844019a3a067481c8d9cb70c7a2ba447>:0)
UnityEngine.UnitySynchronizationContext.Exec () (at <844019a3a067481c8d9cb70c7a2ba447>:0)
UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at <844019a3a067481c8d9cb70c7a2ba447>:0)```
#

and in my build i have specified MainMenu

dense pasture
#

Are there any issues with xNode in a long term project? I’m loving the simplicity and it does what I need to get my cinematics system into a node graph format. Curious if anyone has any comments to add about the library

sweet raft
#

I normally don't dabble in first-person stuff, but I have to for a small project I'm working on. I'm just having trouble separating my characters Y axis rotation from the camera's X axis rotation. I put them in separate scripts, and the character's rotation is just how I want it (following the mouse's X), but the camera is jittery. The camera is a child of the player (so that it moves with the player as they walk), and it's set up to follow the mouse's Y, only rotating on its X (looking up and down), but whenever the player moves/rotates, at the same time as the camera, it's not smooth. (This is for a very early prototype so it doesn't need any high level code [i.e. modifying positions and rotations directly is perfectly okay], so I don't want to download any elaborate assets or bother with something like Cinemachine. In fact the jittering isn't even a worry for the demonstration, but it's just getting on my nerves.) Any insight?

steady moat
sweet raft
steady moat
#

What method you use to move the camera/player ?

#

Do you modify the position of the camera after the player has moved ?

#

Do you appropriately use delta time for both the player and the camera movement ?

stone kraken
#

Cinemachine is extremely easy to setup

#

Then you literally just drag your player to the follow target and basically done

#

(sorry I know you said you didnt want to bother with it already)

simple ridge
#

Hi everyone, I'm working on a procedural generation game and am wanting to add in grass on specific cells, to do this I was going to look into particle systems.

I know you can apply meshes to have particles spawn on them using the ParticleSystem component, but is their a way of directly giving the particle system coordinates to use instead of a mesh. Or separately how would I render particles with manually setting graphics buffers and having this work with the Particle System component or not using it at all?

latent latch
#

VFX graph and graphic buffers I've seen done for grass before, otherwise just instantiating them with instancing upon the coordinates is an idea.

#

Biggest problem is culling which I'm not entirely sure how'd you tackle with large amount, so you'd probably have to make sectors of where this grass would render. Easy enough with VFX graph but I'm not entirely sure how it's handled with general instancing by the pipeline settings as that seems to be handled for you.

#

Unity culls and sorts instanced Meshes as a group. It creates an axis-aligned bounding box that contains all the Meshes, calculates the center point, then uses this information to cull and sort the Mesh instances. Note that after culling and sorting the combined instances, Unity does not further cull individual instances by the view frustum or baked occluders. It also does not sort individual instances for transparency or depth efficiency.

grand aurora
#

Hi, guys. What am i doing wrong?

cosmic rain
elfin quest
#

Hello!
I'm trying to have a custom workspace set up for unity with VSCode. Now I have 2 options:

  • Set my external tools editor to VSCode -> I can check generate .csproj files. (Creating/Deleting scripts updates the csproj) I have to manually open the workspace each coding session and whenever I click on a console log (Opening the relevant file) It again opens the root directory instead of my workspace.

  • Set my external tools editor to my custom workspace directly -> I can't check generate .csproj files. (Creating/Deleting scripts DOES NOT update the csproj, and scripts don't have access to the project). The workspace opens automatically from start and from console logs.

What I'd like:
A way to have the same functionality as seting my workspace as the external tools editor (Everyhhing is instantly opened in the wokrspace). But that it's also "watching" for file changes and updates the local csproj file so that I can actrually create files.

#

Any ideas?

grand aurora
# cosmic rain What does the error say?

The type 'type1' cannot be used as type parameter 'T' in the generic type or method '<name>'. There is no implicit reference conversion from 'type1' to 'type2'.

steady bobcat
#

thats your answer, the type is not compatible with the generic function arg

grand aurora
#

i just need to change LensDistortion value

steady bobcat
#

perhaps lens distortion is from something else and not post processing

#

(the type you are using i mean)
is this URP/HDRP or built in old post processing?

steady bobcat
#

Huh well LensDistorsion is a VolumeComponent so i can only guess you have something else that has a type with this name

grand aurora
steady bobcat
#

great. now you know what to check in future too 👍

simple ridge
round violet
#

idk why but when I instantiate a prefab at 0, 0, with a parent, its local positon is the parents position

so if the parent transform is 10, 10, intead of spawn at 10, 10 + 0,0 the child is spawning at 10,10 + 10,10

latent latch
cosmic rain
round violet
cosmic rain
#

Share the code.

round violet
#

indeed, but nothing wrong with at first glance

GameObject lDebug = Instantiate(DEBUG_TO_INSTANTIATE, new Vector2(0, 0), Quaternion.identity, gameObject.transform);
#

parent (gameObject.transform)
and child

cosmic rain
round violet
#

Debug.Log("pos: " + lDebug.transform.position); its indeed correct

#

something is moving the object im spawing i guess

cosmic rain
round violet
#

I did and nothing is touching it

#

im not keeping a ref of it, its a debug spawn

cosmic rain
round violet
#

well afaik its not moving it

cosmic rain
#

Does the object have any scripts?

round violet
#

nope, plain cube

cosmic rain
#

Then try debug break after instantiate line and see if it's moved by then

#

Also share the script where you instantiate it.

round violet
#

spawning the prefab by doing parent pos + relative pos with no parent
then using SetParent(parent, true) works

#

so this is a workaround but idk why its needed

cosmic rain
round violet
#

yeah i know, i might later on find why this happens

steady bobcat
#

you can just set world pos after instantiating something...

round violet
#

when i edit the transform.position of my child, is it the world or local pos ?

steady bobcat
#

.position is world position always

#

regardless of what the transform hierachy above is it will do the same thing.
localPosition will be its local position to its direct parent always (if no parent, is world)

obtuse canyon
#

is there a way to change a scene camera refresh rate or more preferably do it manualy, basicaly like a photo

latent latch
#

what's the use case

obtuse canyon
latent latch
#

not sure if there's like a capture once method for the camera, but you can just render a single frame onto a render texture then disable the camera, repeat

obtuse canyon
#

I want to do it by having two textures that scroll onto each other and they snap a picture once the other one finnished

latent latch
#

or use command buffer blit method to render once to texture

obtuse canyon
latent latch
#

Basically just pastes the renderer onto at texture inside of the shader

steady bobcat
#

a shader can easily be made to let you reveal one texture over another so then up to you to decide how to capture things to show on it

fiery steeple
#

@steady bobcat there's no sceneDirtied member, so I guess it's called sceneDirtiedCallback because that's what my IDE suggest me ? 🤔

steady bobcat
#

Are you on some ancient version?

fiery steeple
steady bobcat
#

ignore your ide and copy paste what i sent as it should exist. The suggestion is for the delegate type that this event uses.

vestal arch
vestal arch
#

yeah you can't use statements in a class context

kind river
#

I have a script that populate an UI when Domain Reload :


        
        [InitializeOnLoadMethod]
        private static void OnDomainReload()
        {
            var mainHUDMonitor = FindFirstObjectByType<MainHUDMonitor>();
            if (mainHUDMonitor != null)
            {
                mainHUDMonitor.Save();
            }
        }

The issue I have, is that my UIDocument doesn't have rootVisualElement at that time. It work correctly once in game or in editor after the whole domain reload. I thought I could fix this by subscribing to the UIDocument, some kind of "OnRootVisualElement" method. But I'm not sure which one to use https://docs.unity3d.com/6000.0/Documentation/ScriptReference/UIElements.UIDocument.html
I guess the OnEnable, but I wanted to know beforehand if someone know a better/proper solution

fiery steeple
steady bobcat
#

mb for not catching that. you can subscribe to the event in Awake() for example

#

you however need to add [ExecuteAlways] to this class to make this work in edit mode

fiery steeple
#

I tried this but I have an error

vestal arch
#

well that's not how lambdas work

fiery steeple
#

tell me more please

vestal arch
fiery steeple
#

what does "scene" stand for ? I guess I have to pass a scene, that's why I'm passing the current active scene but it doesn't work 🤔

vestal arch
#

a lambda is a shortcut/anonymous method
the parts before the => are the method's parameters
the part after is the method's body (or an immediate return value)

vestal arch
fiery steeple
#

So now what should I put in that lambda ? 🤔

steady bobcat
#

You can also do:

EditorSceneManager.sceneDirtied += MyFunction;

void MyFunction(Scene scene){}
#

anyway try to use the event to refresh the list of colliders

fiery steeple
#

Like this ?

steady bobcat
#

Yes. hopefully this will be called on each scene change but something makes me think it may be only the first dirty 🤔
I remember fiddling with it in the past but i forget

fiery steeple
fiery steeple
#

it complains 😕

#

fixed but now it creates an error in the console

#

setting line 12 to static created that issue

#

like so ?

steady bobcat
#

nvm im dumb you never set it to a value

#

why did you make it static?

fiery steeple
#

let me remove it to show what was the complain

steady bobcat
#

no its because you made the method you subscribed to the event static so it can not access instance fields...

fiery steeple
steady bobcat
#

^ read above

fiery steeple
#

nevermind it doesn't complain anymore 🤔

#

so I remove the if statement now or do I leave it there ?

steady bobcat
#

yea i think you did something else wrong and confused yourself

fiery steeple
#

yeah 😄

naive swallow
#

Remove all the statics. Create an empty list in your field initializer

steady bobcat
#

Btw you need to un sub from this event in OnDestroy() to avoid errors in future @fiery steeple
do the same as a sub but instead do -=

naive swallow
#

An empty list and a list that doesn't exist are not the same thing

#

One of them is a shoebox with nothing in it. One of them is a sudden and suspicious lack of shoebox

fiery steeple
steady bobcat
#

You may need to call the refresh func on awake too so on load it also refreshes this list

#

and remember this event isnt called for all changes (annoyingly)

naive swallow
fiery steeple
steady bobcat
#

i looked but was the best i could find.
No its serialized so they dont as its used after Awake

fiery steeple
steady bobcat
#

yes

steady bobcat
steady bobcat
#

er yea i have no idea what thats on about or why

flint anchor
#

I've been having issues with Camera.Render on Ipad ever since Unity 6, i'm rendering to a render texture and putting it in the UI and it totally works in editor but on device it does not work. Are there any known changes that affect this? Or something in the engine that I have to tick?

naive swallow
naive swallow
#

yes

fiery steeple
steady bobcat
fiery steeple
steady bobcat
#

did you add to update that list on Awake too? can only presume its not and nothing changed to make it happen yet

fiery steeple
# steady bobcat did you add to update that list on Awake too? can only presume its not and nothi...
#if UNITY_EDITOR
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

[ExecuteAlways]
public class DrawBoxCollider : MonoBehaviour {

    public List<BoxCollider> boxColliders = new();
    public bool scanForColliders;

    private void Awake()
    {
        EditorApplication.hierarchyChanged += OnHierarchyChanged;
        OnHierarchyChanged();
    }

    private void OnDestroy()
    {
        EditorApplication.hierarchyChanged -= OnHierarchyChanged;
    }

    void OnHierarchyChanged()
    {
        boxColliders.Clear();
        boxColliders.AddRange(FindObjectsByType<BoxCollider>(FindObjectsInactive.Exclude, FindObjectsSortMode.None));
    }

    /*void OnValidate() {
        if (scanForColliders) {
            boxColliders.Clear();
            boxColliders.AddRange(FindObjectsByType<BoxCollider>(FindObjectsInactive.Exclude, FindObjectsSortMode.None));
            scanForColliders = false;
        }
        
    }*/

    private void OnDrawGizmos()
    {
        if (boxColliders == null) return;
        foreach(BoxCollider boxCollider in boxColliders) { 
            Gizmos.color = Color.green;
            Gizmos.DrawWireCube(boxCollider.center + boxCollider.transform.position, boxCollider.size);
        }
    }
}
#endif
primal oar
#

code works when executed in frames but not at normal speed

clear basin
#

guys why can simple 2d scene not load with LoadScene() in the build of my game (in editor it loads)?

leaden ice
clear basin
#

yes

leaden ice
#

so what happens when you try to load it

clear basin
#

nothing, game stays at the same scene

leaden ice
#

Have you looked at the player logs?

clear basin
#

no, let me check (i forgot about it)

clear basin
#

@leaden ice i just added some log messages so it would be easy for me to find messages after running LoadScene() but i didn't find anything that would make sence for me

#

this is everything it wrote after my debug message about loading that scene

naive swallow
#

Is Async/Await significantly more efficient than coroutines? I have a bunch of coroutines to load data from disk without blocking the main thread, and I'm spending roughly 85% of my frame on GC.Collect from them. Could I cut this significantly if I reworked my coroutines into async/awaits?

stable osprey
#

Although 320ms for coroutines GC doesn’t sound like a coroutine issue

naive swallow
#

I can't drill down any further than that in the profiler, so I don't know what else it could be

thick terrace
#

coroutines only shift work around on the main thread though, if it's disk IO maybe you can run it on a background thread using async?

latent latch
#

Can also just reuse the coroutines

thick terrace
#

yeah, if you're starting enough coroutines that the GC from coroutines alone is a problem, starting less coroutines is probably where to look first 😄

leaden ice
#

Are you sure you're looking at the player logs and not the editor logs?

clear basin
#

and i actually don't understand how did i fix it

eager tundra
naive swallow
#

The actual Disk I/O is done on another thread, through a plugin called TriLib. I'm not entirely sure how it handles those, to be honest. The coroutines I'm starting are just so I can space out the mesh loads, so I can sequence them one after another, and pop them in as they load. The coroutines themselves are mostly just "loop over a bunch of things with a yield return null in there so it does one iteration per frame".

All told, there's only two coroutines actually being started, but those are some hefty coroutines, and each one spins up a few threaded processes through the plugin. There's still a lot I can do to try to optimize these, I just wanted to know if simply switching to async/await would be a huge difference, or if I need to drill down deeper. Seems like it's the latter.

steady bobcat
#

Sounds like its the work and not the way its made "async" so probably wont matter
Though if the lib has async functions its probably better to await those vs looping and checking each update in a coroutine

#

And to remind you, File has async functions too and libs like UniTask and Awaitable make it easy to go back to the main thread (if something awaited completed on another)

naive swallow
#

Okay, I think I've found where the problem is, and I don't know how I can make it any more concurrent - the problem seems to be where it sets up all the objects it loads by adding several components to them and setting their properties. Since it involves AddComponents, I can't offload it to another thread, and there's literally thousands of them so it's just gonna be slow

fossil obsidian
#

Hi guys. I want to do a puzzle in my game where you have to clean your computer because you've dropped coffee on it, so you have to take a cloth and rub it without accidentally turning it off or tearing off the wire. So I want the player to hold the mouse click and rub it around the pc and gradually clean it, similar to a task from among us. But idk how I'd make the code recognize the mouse position and compare it with where it needs to be to clean it

naive swallow
fossil obsidian
#

ty

livid shard
#

Wanted to share this here ... a file from my machine learning pipeline that implements the OpenAI API schema for C# and C# (CSX) scripting. I implemented this long before there was an official NuGet package, but it's still useful in this format for Unity, notebooks, dev-ops, scripts, etc.

https://gist.github.com/atcarter714/7de44cd439ab7deddf7cd25fb8de4e57

Gist

A C# script file (CSX) implementing the OpenAI API (also works as regular C# code) ... - AssistantsSchemas.cs

astral sky
#

is it normal for Audio to take like all processing of a frame?
In other words, have anybody seen this before

#

btw i have no audio or audio clips or etc. whatsoever

#

can this be a driver issue? I just updated my system

cosmic rain
astral sky
#

well it absolutely wasn't like that before and now i have 10fps

#

updated drivers award

cosmic rain
astral sky
#

the audio thread is taking 99.9% of total

#

everything else is just idle waiting for the audio to finish

#

I'll just have to debug this, maybe the update messed with the clock speeds of the audio driver, not something Unity is at fault I guess

cosmic rain
#

Obviously, on the audio thread it would take 100% of time

cosmic rain
astral sky
#

Editor loop: 97% of total

#

96ms

cosmic rain
#

You can switch to editor mode if you want to investigate it.

astral sky
#

Okay I see, I haven't actually used the profiler that much other than to see "line stay low"

cosmic rain
astral sky
#

...It's just the editor setting itself to idle?

#

Okay, window manager issue, Unity thinks its being run in the background or is tabbed out when it actually isn't

#

Just changed my window display mode and its gone, very bizarre but I guess I learned how to use the profiler better

steady bobcat
#

i get this too, ui refreshing will be throttled when i focus a floating window but when i click the main window again it fixes it

cosmic rain
astral sky
#

I'm not as far as being able to build but I'll keep it in mind!

cosmic rain
#

You can even build an empty scene.

lament dragon
#

I want to make an array of scripts, like how you can use float[] or GameObject[], and then be able to iterate through that array and do something like GameObject.AddComponent(ScriptArray[index]). Is this possible, and if so, how could I do it?

night harness
lament dragon
night harness
#

Just asking to adjust how I respond, are you new to c# and/or Unity?

lament dragon
#

Never taken classes on it, all my knowledge is self-taught, but I have been working in C# for 5 years and in unity for 3

#

I'd rate my knowledge as somewhat base level but I know what I'm doing

night harness
#

Ez, just asking because a lot of people with more non-unity c# experience tend to go about doing stuff that way in my experience

Ideally you would be spawning prefabs here that have the associated creature script/s on it. This would be done either be directly referencing the prefabs and/or maybe in the future using a paired scriptableobject that has the prefab

lament dragon
#

Hmmm, I could do that...
Though they need to be easy to reference. Because of how the game works, all creatures need to be referenced from one of a few scripts since most of what they do is responding to stimuli from those scripts. I've thought about using prefabs but I don't know how I'd reference them without making a bunch of variables for each instance.

night harness
#

Could you give an example or two of the variables per instance your worried about making/

lament dragon
#

Basically what I'm saying is there are methods run in one main script. Those methods will affect the creatures. I don't know how I'd do that cleanly if I used prefabs for the creatures
Because if I used scripts for each active creature all on one the same object, I could just do if(object.HasComponent(script)) { Method(); }

#

The "creatures" don't actually have an appearance or anything, they're more like conditions or events that happen in a day

#

I'll just call them what they are: anomalies. I want to make it as easy as I can to expand the list of anomalies and make more in the future.

warm badger
#

maybe this is not purely code related question but more of a game architectural issue. whatever i am leaving this here to find some good advice. Suppose you have your character equipped with multiple mechanics. Your player can move, ride a bike, swim, fly a glider etc. How do manage all these? like in case of riding, you have one set of bike camera, bike manager and bike movement scripts. again for the glider you have almost same set with completely different code base ( because the glider runs on different logics, different movement code etc ). and also for swimming you have somewhat a bit different logics. now in this case how you manage all these whole lot of scripts for each type of mechanism? How would you enable and manage set of script for each mechanism? I hope I have explained it properly.

cosmic rain
warm badger
cosmic rain
#

Or what other options you are considering.

cedar terrace
#

does anyone know why my movement's wrong?
I wrote a script for walking & switching the animations between walking and idle,
and the states should be fine,

but when I walk (like in the video) it only works with left & right;
then it freaks out whenever I walk down.

muted maple
#

Is your animator set up correctly? I faced plenty of animation problems, and usually it’s a simple mistake and me being an idiot.

sudden ruin
#

hey not a unity question but can every single class in the project followed by some design pattern? Should i force myself make them all follow a design pattern ?

lean sail
vestal arch
#

you could consistently use a given pattern in your project, but that doesn't mean "make every class follow it"

sudden ruin
#

I meant every class follow somes sort of pattern not all follows one single pattern

vestal arch
#

again, not really, design patterns aren't class-scoped

#

they're more like feature-scoped

sudden ruin
#

Every class coded for a feature right ?

vestal arch
#

you don't have to stuff a design pattern into every class. not every class needs one.

put design patterns where they're needed. more design patterns doesn't mean better code

vestal arch
#

i think you're seeing design patterns as more than they are. they're a tool in your arsenal to solve problems, they aren't meant to be used everywhere

sudden ruin
#

Maybe i should just think can this feature used with any pattern then code it

vestal arch
#

yeah, not every feature needs a pattern

#

design patterns aren't your goal
your goal is a game, and design patterns are just a tool to help in that goal
sometimes they're useful, sometimes they aren't

lean sail
vestal arch
#

i mean, you would probably make that a struct

lean sail
#

just an example. I couldve made it 20 numbers and suddenly a struct is bad

vestal arch
#

and you wouldve used an array instead and it could still be a struct

#

ah, wait. thinking in c structs. that doesn't work the same way, nvm

lean sail
#

the point is, a class doesn't mean you're making a whole feature

#

A pattern is a guide on how you could implement a common problem. you dont have to use any patterns at all!

vestal arch
#

my point is, this is data without behaviour, so i don't think a class makes sense here; it's a bad example

#

but well, im not coming up with anything better, and the point has been made, so shrugsinjapanese

sudden ruin
lean sail
vestal arch
#

imo a better example would be a class that actually has behavior, but without needing a design pattern

vestal arch
vestal arch
lean sail
sudden ruin
lean sail
#

I've seen people use builder or factory but it's always just looked overcomplicated for the use case.

#

If you go more into web dev, that's when people really start to go heavy on patterns I think.

noble marsh
#

Ugh racking my brain on a weird issue. I'm relatively new to Unity. I'm generating a mesh at run-time in an ECS System. When I capture a frame in NSight and look at the vertex buffer, the coordinates don't make sense to me. It's almost as if the vertex buffer is being transformed such that positive x goes to the left.

north cypress
#

hey guys.

On my game launch on the mainMenu when the player presses start it loads up another scene. This secondary scene is intended to play my GameStudio Video for 3 seconds, before a c# script boots up the main game. The button works and it boots up the gamestudio scene, but the video does not play and instead we are greeted with the void, for 3 seconds until the c# script boots up the main game. If i disable my c# script, the button boots up the correct scene and plays the video, but does not go to the maingame after 3 seconds. I'll attach a screenshot of my c# code and 2 example videos of what occurs when I enable and disable my c#

Any Help Would Be HUGELY Apreciated. Thanks.

vestal arch
# north cypress

Start is called on the first frame the object is loaded, and it runs to completion before the frame is "done"

north cypress
#

@vestal arch , I attempted to use update() but it threw some error at me

vestal arch
#

you need to split that across multiple frames, so the logic should be in Update without the while, or use a coroutine where you can just specify WaitForSeconds(3)

north cypress
#

I'll show you one sec 🙂

#

It's not doing the error now XD

#

But it still won't work

vestal arch
#

what's your current code?

north cypress
#

wrong video oops

vestal arch
#

see !code

tawny elkBOT
vestal arch
#

don't need a video right now, need your code

north cypress
#

using UnityEngine;
using System;
using System.Threading.Tasks;
using UnityEngine.SceneManagement;
using System.Threading;
using Unity.FPS.UI;

public class PlayGame: MonoBehaviour
{
float delay = 3;

public void Update()
{
    while (delay > 0)
    {
        delay -= Time.deltaTime;
        if (delay <= 0)
            SceneManager.LoadScene("MainScene");

    }
}

}

vestal arch
# tawny elk

please format it appropriately
don't use screenshots for text

north cypress
#

my appolgies

vestal arch
#

Update is already a loop, you don't need the while

north cypress
#

bruh that was it

#

LIFE SAVER

#

Thanks man i rlly appreciate it

#

( im also aware i look rlly stupid cuase that was so simple lol )

#

thanks bro

vestal arch
north cypress
#

thanks

#

I have this error now though

#

anything to worry about or ignore it?

vestal arch
# north cypress https://paste.mod.gg/mwewrgsdxkxk/0

also, footnote:
without the while, technically, once the timer reaches 0, it'll do the loadscene every frame. since it's synchronous in this case, it'll load in the following frame (making the object unload and not loop), but that's kinda specific to this function
if you use this pattern for anything else, or if you change it to load async, you'll have to make sure it's only called once. you could have the while as an if instead, or you could use a coroutine

vestal arch
loud oasis
#

k guys i need some help, i've been working on this for like an entire week an i can't figure out how to make it work. So basically i'm trying to make it so that if the player does something like move left it adds a number like "1" in a list for every frame he's moving left, then the other game object (echo) will check the list if it's 1 then it will move left, if its 2 then it will move right, but for some reason it just spawns and does nothing

tawny elkBOT
vestal arch
#

and show more context there, like what's agenda? etc
this is an incomplete picture

#

secondly, if you do this based on frames, it'll end up inconsistent if framerate fluctuates

loud oasis
#

so how should i do it

vestal arch
#

hold on what are you trying to do exactly?

#

like what's the end goal

loud oasis
# vestal arch like what's the end goal

Ok so let's say the player moved left for 3 seconds then the player moves right for 2 seconds and jumps, then after the player presses a specific key it's going to spawn another game object which will do the exact same thing the player did

vestal arch
#

later, correct?

#

i'd guess doing it based on time or distance would be better

wintry crescent
#

Is there any difference at all between UNITY_ANDROID and PLATFORM_ANDROID?

leaden ice
somber tapir
#

if you are not planning on having a delay between the player and echo why not simply copy the rigidbodies' values?

last quarry
thorny rock
dense coral
#

Hi! I have a class constructor like this

public InventoryItem(InventoryItemSO itemTemplate, int amount)
    {
        this.itemTemplate = itemTemplate;
        this.amount = amount;
    }

Problem:
I pass itemTemplate reference from a gameobject that i destroy right afterwards and my InventoryItem's instance field itemTemplate becomes null. (InventoryItemSO is a ScriptableObject class)

  1. Why does this happen? I guess, it's a class and hence a reference type. But shouldn't my field reference the same memory(file)? Why deleting one of the references has an effect on others?
  2. In concept i have an expectation: ScriptableObjects are supposed to help with saving memory as multiple gameobjects can reference one ScriptableObject file. How do i achieve that? There is some CreateInstance and Instantiate that can be used to (from what i understand) copy scriptable objects. But it seems to me that it would defeat the purpose.

Please point out any misconceptions that might be present in the question

night storm
lean sail
# dense coral Hi! I have a class constructor like this ``` public InventoryItem(InventoryItemS...

can you show how you use the InventoryItem ctor? Like what code calls this constructor and passes the value. If itemTemplate is a scriptable object, it won't go null because of a game object being destroyed.
My first thought would be maybe you're just passing in null and didn't realize, or are setting it to null at some point. 2nd thought could be, are you possibly destroying the SO which should be possible if it was an instance made using Instantiate or CreateInstance.
As for your 2nd question, you dont need to use either function, you mostly should be creating scriptable objects as assets. It will be an actual file under your assets folder. It's the same way multiple game object can reference one prefab.

lean sail
# dense coral Hi! I have a class constructor like this ``` public InventoryItem(InventoryItemS...

I dont think of it as saving memory truthfully, that could be a possibility but in most cases we'd be talking in terms of bytes saved, an insignificant amount. If you wanted to modify the data, you have to copy it from the SO, meaning your class would be storing all the same fields. (otherwise you'd be changing the data which everything else is referencing). In this case I don't see how any memory is saved.
The best use really is that it stops you from having to define a set of values in code or on game objects (prefab or in scene). Also compare the git changes of modifying a scriptable object and modifying object in scene. One is much more clear

viscid plaza
#

Yo. Excuse the trashy hacky code, but I am trying to create an object that can "flatten" terrain under it. Problem is, this only works for objects I place in the editor before hitting play. Anything instantiated during runtime or dragged in during play mode just ignores the terrain flattening.
https://paste.mod.gg/vavsywdukhkv/0

Edit: I was using GameObject.Find instead of transform.Find. Code became 10000 times more performant too.

worldly stirrup
#
    {
        RaycastHit2D hit = castRayLevel(rb.position, -checkPos.transform.up, currentSlopeCheckDown, Color.red);
        Vector2 offset = Vector2.zero;
        bool isMiddle=hit;
        if (!isMiddle)
        {
            var rays = fireOtherRays((Vector2)transform.right, -checkPos.transform.up, currentSlopeCheckDown, Color.red);
            hit = rays.Item1;
            offset = rays.Item2;
        }
        grounded = hit && !isJumping; 
        if (grounded) getGroundValues(hit);
        else resetGround();
        sloped = Mathf.Abs(slopeDownAngle) != 0f;
        rotatePlayer(slopeDownAngle, rotationGround, offset);
    }```
latent latch
#

When in doubt, use more raycasts

worldly stirrup
#
        Vector2 offset = Vector2.zero;
        bool isMiddle=hit;
        if (!isMiddle)
        {
            var rays = fireOtherRays((Vector2)transform.right, -checkPos.transform.up, currentSlopeCheckDown, Color.red);
            hit = rays.Item1;
            offset = rays.Item2;
        }
        grounded = hit && !isJumping; 
        if (grounded && funcs.getAngle(hit.normal,Vector2.up)!=90) getGroundValues(hit);
        else resetGround();
        sloped = Mathf.Abs(slopeDownAngle) != 0f;
        rotatePlayer(slopeDownAngle, rotationGround, offset);```
rigid island
#

are you overriding the velocity ?

worldly stirrup
#

This video shows that my solution works, but when I jump back on this slope, this happens

rigid island
#

yeah so basically need to only do it if you're on a downslope vel

worldly stirrup
rigid island
#

I suppose you'd only apply that fix when its velocity / angle is on a downslope

#

everything else I don't know much about your original sticking walls thing

vestal arch
viscid plaza
#

Probably, it was just the easiest way to do it. The thing was, I was finding the same plane in the scene each time, instead of finding it in its children.

wanton acorn
#

I'm trying to generate random NPCs like if it was Papers Please, so like their sprite, if they are allowed or not, and other characteristics, but I don't know where to start. Any suggestions?

naive swallow
#

Define each value that can be randomly rolled.
Put each value into a list.
When it comes time to generate, roll a random number between 0 and the length of the list and pick that value

wanton acorn
#

But for example, if a character was assigned the fox race, they will have a higher probability of being evil. How can I do that?

vestal arch
#

give your random rolls weights

#

there's a lot of ways to achieve that

#

try googling to start

wanton acorn
#

My problem is assigning different random roll weights to different races, and I couldn't find that on google

vestal arch
#
  • roll race
  • choose weights based on race
  • roll <value> using weights
#

could be a map of races to weights, or could be a massive switch..case

spark yarrow
#

Hey, im currently working on a game concept heavily inspired by celestes movement system, and im having trouble implementing the actual carrying of momentum after dashes. I have omnidirectional dash down, but im struggling to figure out how I can carry it or amplify it correctly. Can anyone help me out?

wicked mountain
#

My first thought is to save velocity when you press the dash button, then apply your dash, then, reapply the saved velocity on exit

spark yarrow
#

maybe

#

Ill give it another look later and see what I can do. Last time I tried to do something similar to that it screwed itself up royally (i have no idea how to code)

rigid island
#

this is like the 4th question I've seen about Celeste lol

spark yarrow
#

its a kickass game with amazing movement what can I say

rigid island
#

there is a pretty good vid on YT that explains some of it

spark yarrow
#

yeah I saw that one

#

its good but i dont think it covers wavedashing

#

which is what im looking for really

rigid island
#

maybe post what you tried, surely someone can figure something out

spark yarrow
#

Ill do that when I get home, im currently in class lol

echo haven
#

anyone have an issue where you can't destroy a script because the script relies on itself??

#
Can't remove BuildingPlacementVisualizer (Script) because BuildingPlacementVisualizer (Script) depends on it
steady bobcat
#

did you put a silly RequiresComponent ?

echo haven
#

i have requires component but it doesnt require itself

#

and the scripts it requires does not require it

#
  [RequireComponent(typeof(Building))]
    [RequireComponent(typeof(BoxCollider))]
    public class BuildingPlacementVisualizer : Equippable
#
    public abstract class Building : MonoBehaviour, IInteractable, IHoverable
#

ok i fixed it

echo haven
rigid island
#

requiring an abstract class as component ?

echo haven
#

I had a requires component of a type I was inheriting from

#

forgot to take it out lmao

steady bobcat
#

eyy easy fix 👍

echo haven
#

lfg

digital crater
#

idk how people are with Playmaker in this server, but would anyone know why my enemy would be running away from the player? The states transition fine, just the enemy seems to want to run away

somber nacelle
#

pretty sure playmaker has its own community you can get support in for it

#

otherwise there's the #763499475641172029 server, but that's likely limited to just unity's visual scripting

dense pasture
#

form question: do i need yield return on the top one or just return works for coroutine chains?

vestal arch
#

pretty sure both work, just in different ways

dense pasture
#

i guess my question is, is it waiting for the next frame to drill down with yield?

#

just been curious about it for a bit

vestal arch
#

if it's just a return, then it's just... giving the IEnumerator object directly from the other function
if it's yield return, then it's delegating control to the other enumerator

vestal arch
#

unity receives what you yielded and processes the result accordingly

dense pasture
#

i was under the understanding it tells the coroutine to resume on the next frame

vestal arch
#

that's what happens when you yield null
unity does that

dense pasture
#

ah k

#

that clears it up thanks

digital crater
thick terrace
dense pasture
vestal arch
#

wait i mightve used an incorrect assumption one sec

dense pasture
#

Like it just pretended the routine ended. I don’t remember the details now tho

vestal arch
#

c# doesn't do delegation, you end up yielding the entire enumerator

thick terrace
thick terrace
dense pasture
spark yarrow
#

The momentum weirdly enough carries correctly in the upwards direction but not horizontal, even for diagonal dashes.

hollow swan
#

Okay small question. i've been looking for a while pretty much nothing really show how to place tree on terrain and how to remove it with script. without just using gameObject cause i wish for my computer and the one of other to stay alive.

rigid island
#

you want to remove a tree from the terrain during runtime with a script ?

#

the tree from terrain component ?, arent those just prefabs of gameobjects ?

hollow swan
#

the only way i can access them is through the the TreeInstance component from what i red

#

it not really a game object from what i've seen

wicked scroll
hollow swan
#

which is why i can't use script on them directly and i must pass through "TreeInstance" or just "Terrain" in general

#

And could you give me an exemple of script i could use to go through the whole array of tree to remove a specific one?

rigid island
wicked scroll
#

no, but I bet you could find one if you google 'unity remove terrain trees'

#

basically I think you'd take the world position of the tree, convert that to the normalized terrain position, and then remove the tree at that position?

wicked scroll
#

I think maybe they can, if your tree prefab does? but then it's still not rendered like a normal GO

hollow swan
#

Yeah but like i don't know how to remove the tree itself i don't find anything inside TreeInstances

rigid island
#

last time I used terrain was 3 years ago so I'm fuzzy on this one

wicked scroll
wicked scroll
#

it might be very heavy to do that though

wicked scroll
hollow swan
wicked scroll
#

I have a vague recollection that it doesn't work though, like the collider in the tree instance is just ignored (but I'm not 100% on that)

wicked scroll
rigid island
hollow swan
#

Same but it just piss me off

wicked scroll
#

unity's terrain system is so bad that it's not worth doing anything with imo

hollow swan
#

Why can't they just make some function to you know place or remove one simply

rigid island
#

will test it now

hollow swan
#

i mean i know it's not as simple as that of course but just can't they make a system that make sense when they are such a big company

wicked scroll
#

yes, it would be nice if unity had a good terrain system

#

there are good ones on the asset store that people use instead, so maybe it's not a high priority for them

wicked scroll
chrome pawn
#

I want to transition from an isometric perspective, into a third person perspective while the right mouse button is being held. When transitioning to third person from isometric, I must make sure that the player aims at the direction that their mouse is when they were in isometric. The third person camera will have an offset, which means that I must account for this when trying to aim the third person camera to the right direction. The picture shows my thinking in solving the problem. The yellow dot is the horizontal camera offset from the player's character before being offset again backwards to reach the final green point. Then I would make the camera face the red point to get the right aim direction. I however wonder if there is a way to get the same result without knowing the mouse position but knowing the direction towards the mouse from the player's character. I don't believe it is possible but maybe I am just uninformed. Or is there a simpler way?

#

Sorry if its too long jaja

leaden ice
hollow swan
patent perch
#

Hi
I'm making a bullet hell/ space shooter and idk where I should put my logic on when I hit something, I should call TakeDamage (on healthManager or from bullet script?)
For now, I just have 1 bullet script and several healthmanager (inherit) but I have an interface to TakeDamage
What should I do? Because I think i will have more than one bullet script (like a beam with raycast?)

leaden ice
chrome pawn
wicked scroll
leaden ice
#

in the topdown mode it's aiming at the blue objects and when it transitions it's aiming at the orangish white things

wicked scroll
#

the answer is probably 'let cinemachine do it'

#

set up each of your cameras and transition them and cinemachine will do a blend for you, and you can tweak that to your heart's content

chrome pawn
wicked scroll
#

oh, well have a second camera that's always doing that and cut to it like they do in the video

chrome pawn
#

What I am asking is if there might be better method of which I am not aware of? Not necessarily two cameras, as the second would have to be updated like I showed anyway

wicked scroll
#

because unlike in the video, you want the crosshair to be pointing at the same in-world spot after the zoom?

wicked scroll
#

I can't think of anything simpler than 2 cameras

chrome pawn
#

I am lacking in the math skills for this, so I wonder if its even possible to do it with knowing the mouse position, but just the mouse direction

wicked scroll
#

I think that they are doing exactly what I suggested: you can see that when they transition to the second camera, it's pointing to exactly where they were pointing before the transition

#

then it zooms in and is pointing at the wrong place

#

you can do the same thing, except pull the camera back so that it's zooming into that location instead of...through it?

#

maybe you're right though and you'd need to do some fancier framing? I'm not sure

chrome pawn
#

I get your 2 cameras idea because it makes sense, it seems easier, but the second camera would still need to go through the calculation of the transition so that, when it switches, it aims at the right direction

wicked scroll
#

yeah, if you want to have the camera do a zoom and end up somewhere, you need to be able to position it there, but I'm still not seeing the problem with that

#

if the camera zooms into a particular offset from the character, you already know where it needs to end up

#

so you can point it from there to wherever it was aiming, and then pull it back (and then zoom it in after transitioning)

chrome pawn
#

I am not copying the zoom from the video, just the change in perspectives

wicked scroll
#

then I guess I really don't understand

chrome pawn
#

Well, you see the mouse position when it is in isometric? When they transition to over the shoulder, they aim where the mouse was while in isometric

wicked scroll
#

You have 2 cameras. One is positioned back, aiming at where the cursor is pointing. The other is positioned over the player's shoulder, aiming at that same position. You can swap between them whenever you want and they'll both be correct.

chrome pawn
#

Yeah, I know, but my problem is not determining if I need two cameras, my problem is with the math to determine the direction to face the second camera

wicked scroll
#

shoot a ray at the world and look at the point it hit

hollow swan
chrome pawn
#

Not in the isometric perspective, in the over the shoulder perspective

chrome pawn
#

I can't just shoot a ray because the camera is not facing the right direction in the first place before transitioning

leaden ice
wicked scroll
hollow swan
wicked scroll
#

camera 2 can look at the position the ray from camera 1 is hitting

livid inlet
#

do u guys know why when i run my webgl build not in dev mode but in the normal mode it shows this

leaden ice
#

and see what's going on

livid inlet
#

It runs fine when I run in dev mode

leaden ice
#

You already said that

livid inlet
#

Ffs 😭

chrome pawn
#

I wonder if anyone knows if its possible to account for this offset without knowing the mouse position, but just the mouse direction relative to the player's character. Because if the player where to change perspectives while their mouse is closer to their character than the horizontal offset of the over the shoulder camera, it would be impossible for me to figure out where to aim

noble marsh
slim pelican
#

Does anyone know of any particular techniques for getting perfect collision detection at high velocities for 2D kinematic rigidbodies? Names of said techniques are fine as long as they are researchable

wicked scroll
slim pelican
wicked scroll
wicked scroll
slim pelican
#

seemingly made it worse somehow

wicked scroll
#

can you just...move more slowly?

#

increase the scale of everything

#

this talk is very good if you want to understand unity physics and how to get it to do what you want:
https://www.youtube.com/watch?v=NwPIoVW65pE

In this 2015 GDC talk, QWOP creator Bennett Foddy explains how to make your game feel solid without writing your own physics engine or breaking your entire game.

GDC talks cover a range of developmental topics including game design, programming, audio, visual arts, business management, production, online games, and much more. We post a fresh G...

▶ Play video
#

oh also definitely increase your physics timestep from the default if you haven't

slim pelican
#

It's all kinematic

leaden ice
#

You would be using boxcasting or capsulecasting

#

But if the things you might collide with are moving too, those are working on outdated information

slim pelican
#

I know thats what I'm doing, I was just wondering if there were any common techniques for getting nigh perfect collision interactions

leaden ice
#

Using the casts is perfect

slim pelican
#

It's just the ground atm, not anything else moving

leaden ice
#

If the obstacles don't move

#

If you're having issues it's probably a problem with your code

slim pelican
wicked scroll
#

if you don't have a problem then there's nothing to improve!

slim pelican
#

? No I do have problems with it. Like this

#

The way I've been tackling collisions is definitely wrong

wicked scroll
wicked scroll
somber nacelle
#

other objects can be affected by a kinematic body, but a kinematic body cannot be affected by any forces (including collisions)

slim pelican
somber nacelle
lost knoll
#

Moved this 🙂

somber nacelle
#

for future reference, use #🔎┃find-a-channel / id:browse to find the most relevant channel to ask for help in. and make sure you actually ask a question

lost knoll
#

Its been corrected thank you.

jolly mortar
#

Hey all. I have a bit of a coding best practices question. My game is getting somewhat complex and I ended up breaking a seemingly small part of the script and broke multiple other scripts as a result.
I guess I want to know what are the best practices when separating your scripts.

Currently I have these scripts:
-Player movement, which checks inputs and moves the character accordingly.
-Camera, checks for inputs and moves the camera and also switches to different angles when certain buttons are pressed. Also rotates the player so their rotation is relative to the camera.
-Health script, which keeps track of player health. I want to use this for multiple enemies too.
-Respawn script, sets player health to 0 if they fall out of bounds, activates the game over screen when health is 0.
-Game controller (bad name I know), keeps track of how many coins and collectibles the player has and displays it on a UI element.
-Coins and bullets also each have a script on them that updates the game controller when u get a coin and bullets update the health script when u get hit by a bullet.

Looking for recommendations on if this organization is any good or if I should combine any of these scripts or separate their functionality into different scripts.

compact spire
#

@jolly mortar To me it seems like they are broken down appropriately.

jolly mortar
#

Thanks

leaden ice
slim pelican
#

all is fine now (i think), I've made a good system PepeJoke

mossy flare
#
    public void VisionCheck() {
#if UNITY_EDITOR
        DebugInfo i = new DebugInfo();
#endif
        foreach (Collider col in Physics.OverlapSphere(transform.position, sightRange)) {
            if (col.TryGetComponent(out Player player)) {
#if UNITY_EDITOR
                i.detectedPlayer = player;
#endif
                Vector3 start = head.position, end = player.rig.head.position;
                if (Physics.Linecast(start, end, out RaycastHit hit) && hit.transform.root == player.transform) {
                    float dot = Vector3.Dot((aimTarget.position - transform.position).normalized, (end - start).normalized);
                    float angleChance = spotChanceCurve.Evaluate(Mathf.Clamp01((dot - maxAngleCos) / (1 - maxAngleCos)));
                    float distanceChance = Mathf.Clamp01(Mathf.Max(Vector3.Distance(start, end), minDistance * 0.1f));
                    float chance = angleChance * distanceChance;
#if UNITY_EDITOR
                    i.totalChance = chance;
                    i.angleChance = angleChance;
                    i.distanceChance = distanceChance;
                    i.hasLoS = true;
                    i.movementChance = 0;
                    i.spotTime = 1 / chance * Time.fixedDeltaTime;
                    i.dot = dot;
#endif
                }
            }
        }
#if UNITY_EDITOR
        info = i;
#endif
    }```
#

Can I make this less fucking ugly?

#

How in the world are you supposed to use compiler conditionals if they mess up your code like this?

rigid island
#

probably split them from Runtime and Editor only components

mossy flare
rigid island
#

wdym out params? just move the editor code to an editor script that works strictly with this component. Then put it in the Editor folder it gets automatically discarded

mossy flare
#

Could you show me? I don't understand.

rigid island
#

you dont need to do all the custom inspector stuff, just make it reference that other script so it OnGui draws gizmos or whatevr

mossy flare
rigid island
#

all ur doing is connecting DebugInfo

mossy flare
#

How would my editor script know about this, this, this, this, this, and this

#

DebugInfo is a private struct (also conditionally compiled) made to store all of these variables specifically

rigid island
#

was under the impression can split those into their own struct for other events or functions

mossy flare
#

those what?

#
#if UNITY_EDITOR
    public struct DebugInfo {
        public Player detectedPlayer;
        public float angleChance, distanceChance, movementChance, totalChance, spotTime, dot;
        public bool hasLoS;
    }
    public DebugInfo info;
#endif
rigid island
#

are these not meant to also be stats like in UI ,just debugs ?

mossy flare
#

Just debugs

rigid island
#

that data wont get saved at all?

mossy flare
#

That's why I don't compile it without Unity Editor

rigid island
#

hmm then I suppose just put them into another method then wrap that in the #IF

mossy flare
#

Them what?

rigid island
#

just the big block

#

I don't see how else you can change the others without using 2 scripts

mossy flare
#

The others what?

#

The problem is that there's like 5 super ugly IF blocks

rigid island
#

all the places you have #IF

mossy flare
#

yeah well that's the issue

#

I guess I'll just get rid of them inside the method and remove any reference to the class when building

#

I was hoping there was a way to do that automatically, like making a class who's references don't exist under compiler conditionals, but oh well

sturdy hatch
#

Will post this here as well, since I don't know if it's the code 100% sure or if it could just be UI hierarchy.

dense coral
chilly surge
#

I'm running into some issues with changing URP settings dynamically at runtime, my current code looks like:

UniversalRenderPipeline.asset.msaaSampleCount = ...;

And it seems to have issues on certain Android devices. Just a sanity check, is it the right way to do it or am I looking at the wrong place?

mossy flare
#

I have a problem. So I run AI vision checks in FixedUpdate for consistency, but I've noticed that it is often missing the player entirely because he has already moved away since the last fixedupdate

#

I thought this didn't affect colliders (fixedupdate physics?), but it does. How do I get around this?

cosmic rain
#

And how are your raycasting? Share some code.

placid edge
#

is there a way i can make some sort of one way tag/layer collision between two separate tags/layer where only one can interact with the other?

leaden ice
# placid edge is there a way i can make some sort of one way tag/layer collision between two s...

Get the BetterPhysics - Selective Kinematics package from Sadness Monday Productions and speed up your game development process. Find this & other Physics options on the Unity Asset Store.

chilly surge
# chilly surge I'm running into some issues with changing URP settings dynamically at runtime, ...

I have a set up that camera is created programmatically at game start, and it seems like the true culprit is if I modify renderPostProcessing of UniversalAdditionalCameraData right after camera's creation, some weird things happen (in my case the symptom is that a custom UI shader doesn't work anymore on some Android devices). I tried delaying modifying that property by 1 frame but didn't seem to make a difference, however delaying by 1 second seems to fix the issue.
This bandaid fix feels incredibly hacky though and I still have no understanding of what the issue is, so I would appreciate it if anyone has some insight.

steady bobcat
#

some things that work for birp to wait for after the current frame being done dont work the same in render pipelines

chilly surge
#

Yeah I wouldn't be surprised if it takes some time to set up the camera or something and only after that it is safe to set the property, but at the same time it also wouldn't make sense because that would suggest a camera that isn't programmatically created would suffer the same issue (because the UniversalAdditionalCameraData should be created at the same time as the camera just like the programmatic creation setup I had)

#

And I have no idea how to debug this issue either, I was only able to find it by bisecting commits then trial and error.

boreal ether
#

I have created my own movement system in another project have now set everything up in a new project for quick reuse. I haven't changed anything about my values. Why is the player suddenly falling so slowly and is no longer grounded

#

In my other project where I develop my game, the problem does not exist

latent latch
#

Well, beyond just telling you to check your gravity velocity, I'd go fool around with the character controller component as you're building off of that which itself may have properties that are modifying the behaviour of what you built.

boreal ether
# latent latch Well, beyond just telling you to check your gravity velocity, I'd go fool around...

That my Methodes so idk in my other projekt it works fine

private void HandleJumpLogic()
{
    if (isJumping && jumpRequested)
    {
        float timeSinceJumpStart = Time.time - jumpStartTime;
        if (timeSinceJumpStart >= settings.jumpApplyDelay)
        {
            verticalVelocity.y = Mathf.Sqrt(settings.jumpForce * 2.0f * settings.gravity);
            isGrounded = false;
            jumpRequested = false;
        }
    }
}

private void CheckGrounded()
{
    bool sphereCheck = Physics.CheckSphere(groundCheck.position, settings.groundCheckDistance, settings.groundMask);
    isGrounded = sphereCheck;

    if (isGrounded && !wasGrounded && !isFirstGroundedCheck)
    {
        jumpRequested = false;
        isJumping = false;
        OnMovementEvent?.Invoke(MovementEventType.Land);
    }

    if (isFirstGroundedCheck)
    {
        isFirstGroundedCheck = false;
    }

    wasGrounded = isGrounded;
}

private void ApplyGravity()
{
    if (isGrounded && verticalVelocity.y < 0)
    {
        verticalVelocity.y = -0.5f;
    }
    else
    {
        verticalVelocity.y -= settings.gravity * Time.deltaTime;

        if (verticalVelocity.y < 0)
        {
            verticalVelocity.y -= settings.gravity * Time.deltaTime * (settings.fallMultiplier - 1);
        }
        else if (verticalVelocity.y > 0 && !jumpRequested)
        {
            verticalVelocity.y -= settings.gravity * Time.deltaTime * (settings.lowJumpMultiplier - 1);
        }
    }

    if (verticalVelocity.y < -20f)
    {
        verticalVelocity.y = -20f;
    }

    characterController.Move(verticalVelocity * Time.deltaTime);
}
#

gravity setting is 20

latent latch
#

Are you debugging the velocity right before it is set?

boreal ether
ivory swan
#

I want to add more features to my fps controller but I'd rather make separate scripts for them. How do I make my fps controller script accessible?

leaden ice
ivory swan
leaden ice
#

Make public methods and properties for the other script to access.

raven perch
#

Pls, someone save me.
I use Visual Studio Code not (VISUAL STUDIO)
and I install Unity extension and then enable Refresh on Save
**BUT **Unity doesn't refresh it in background, **ONLY **if I tab back to Unity itself.
I'm using Unity 6refresh

steady bobcat
raven perch
steady bobcat
#

no idea then. vs just works better so id use that if this is possible for you

night harness
#

if this is the same thing you need to stop asking about it

#

we can't help you if the project is not yours

dense coral
#

Hi! I have a bug that drives me insane.
In my code i have

slots[i].item?.itemTemplate.id (I should always have an object at slots[i], there should be either an item=null or an item with all the fields)

declaration of the class is (notice its not a Monobehaviour)

[Serializable]
public class InventorySlot
{
    public InventoryItem item;
}

Problem is that when i have a gameobject with the script (that holds slots) selected in inspector, it seems like it populates item field for each array element with a new empty instance(like wtf). And it leads to errors. If i dont have the object selected, everything works as expected.
How can i avoid it? How do i have inspector not create instances when it's not supposed to?
I want to see and monitor slots in my inspector

leaden ice
#

it will create a default object for each

night harness
#

not with serializereference right?

#

i thought in that case it just doesnt try to render it but i could be wrong

leaden ice
#

This isn't using SerializeReference

night harness
#

is that maybe a solution to their question?

leaden ice
#

That depends - with SerializeReference AFAIK they wouldn't be able to edit things in the inspector if they needed to, unless they write a custom editor

raven perch
leaden ice
thick terrace
#

it'd be false for the default empty instances of course

night harness
#

(or if you dont need to edit it and just wanna view it using the serializereference attribute as mentioned above)

steady bobcat
#

and hot reload wont solve this issue unless they also make a vs code extension

raven perch
steady bobcat
#

vs does have themes (less i admit) but functionality wise vs is just better

#

so up to you what you wanna do but hopefully something solves it

raven perch
raven perch
steady bobcat
#

Ha i just tried this option in vs and it doesnt work either 😐

dense coral
steady bobcat
#

ohhhh (visual studio)

chilly surge
raven perch
#

only work for Visual Stuido lmao

chilly surge
#

Since VS Code uses the same Unity package nowadays as VS.

dense coral
raven perch
chilly surge
#

VS Code uses the same Unity package as VS, so if that's a requirement for VS's refresh to work, then likely you need to do the same for VS Code's refresh to work too.

chilly surge
#

What?

raven perch
#

I mean what required u talking about?

chilly surge
raven perch
#

Like in the Unity Edior or VSCode?

chilly surge
#

Oops sorry for the ping rob.

raven perch
steady bobcat
#

who summoned me UnityChanOops

steady bobcat
chilly surge
steady bobcat
#

I cannot find this setting in unity to "run in the background" myself so I have no idea

#

I hope its not the same one in the player settings...

raven perch
raven perch
chilly surge
#

Yeah idk either, but maybe VS people know.

#

I wouldn't use it anyways, sounds terrible if your compile time is long and you do multiple edits.

steady bobcat
#

I work on decently size projects and i have a 5-15 s compile time but I have a decent cpu

#

i make good use of asm defs too

chilly surge
#

Do you have domain reload turned off?

steady bobcat
#

I dont that shit never works with how I set up things

chilly surge
#

I've found domain reload to be the the far bigger problem than compile time, and it's not always possible to turn it off depending on if you have code (your own or third party assets) that don't support it.

steady bobcat
#

my domain reload isn't too bad but sometimes takes longer for no reason.
Recently solved a bug where trying to unsub from a firebase event in a destructor caused infinite domain reloading 😐

chilly surge
#

Yeah I feel like domain reload easily takes 4x as long as the compile time that it stops mattering how much I optimize compile time.

#

Hot reload is nice for code changes that are supported.

steady bobcat
#

I shoud look at using it or having a paid one purchased if needed

spiral ibex
#

Hey, I'm trying to create a sprite asset during runtime from dynamically gathered textures that will be used in a TMP, does anyone happen to know some examples I can look into? I am getting lost in the glyph/character etc structure

steady bobcat
long phoenix
#

idk why it doesnt work, its ```c#
public class CarController : MonoBehaviour


in the script, and same name in the directory
rigid island
long phoenix
rigid island
long phoenix
rigid island
long phoenix
#

and imma restart unity rn

rigid island
#

weird things happen

#

cache goes terribly wrong etc.

long phoenix
long phoenix
long phoenix
rigid island
#

ok so let tabs endessly eat your RAM ig 🤷‍♂️

long phoenix
rigid island
#

You shouldn't ignore compile errors..

long phoenix
#

i ignored them, bc i focused on modeling, and testing them in unity

rigid island
rigid island
#

also you wouldnt even be able to Build anyway so yes you need those fixed..
There might be a possibility to refresh Library , after you try restart

long phoenix
#

so thx again

rigid island
#

according to microsoft

// CS0115.cs
namespace MyNamespace
{
    abstract public class MyClass1
    {
        public abstract int f();
    }

    abstract public class MyClass2
    {
        public override int f()   // CS0115
        {
            return 0;
        }

        public static void Main()
        {
        }
    }
}```
long phoenix
cosmic mica
#
transform.localRotation = Quaternion.Euler(xRotation, yRotation, 0f);

how can I make it so it only changes the rotation of the character?

rigid island
rigid island
#

there is context missing here

#

we're not mind reader, we don't know the setup.

cosmic mica
#

mb

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

public class PlayerLook : MonoBehaviour
{
    public float mouseSensivity = 100f;

    float xRotation = 0f;
    float yRotation = 0f;

    public float topClamp =-90f;
public float bottomClamp = 90f;


    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }

    // Update is called once per frame
    void Update()
    {
        float mouseX = Input.GetAxis("Mouse X") * mouseSensivity * Time.deltaTime;
        float mouseY = Input.GetAxis("Mouse Y") * mouseSensivity * Time.deltaTime;

        xRotation -= mouseY;

        xRotation = Mathf.Clamp(xRotation, topClamp, bottomClamp);
        yRotation += mouseX;

        Transform cameraTransform = Camera.main.transform;

        
        cameraTransform.localRotation = Quaternion.Euler(xRotation, yRotation, 0f);

    }
}
#

I think i fixed it

#

nope

rigid island
#

well first things * Time.deltaTime; on mouse Input is wrong
(Mouse input is already returned the moved amount between frames so its already framerate-independent)

#

also when the camera is parented as child there is no need to spin on the Y

#

just spin the Parent object on the Y

cosmic mica
rigid island
delicate granite
#

rotate on the y axis i believe

#

sorry my input was not needed

rigid island
#

eg
cameraTransform.localRotation = Quaternion.Euler(xRotation, 0, 0f);
playerBody.localRotation = Quaternion.Euler(0, yRotation, 0f);

cosmic mica
#
using UnityEngine;

public class PlayerLook : MonoBehaviour
{
    public float mouseSensitivity = 100f;
    public Transform playerCamera;  // drag your Camera here in the Inspector

    float xRotation = 0f;

    public float topClamp = -90f;
    public float bottomClamp = 90f;

    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }

    void Update()
    {
        float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
        float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;

        // Rotate camera up/down
        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, topClamp, bottomClamp);
        playerCamera.localRotation = Quaternion.Euler(xRotation, 0f, 0f);

        // Rotate player left/right
        transform.Rotate(Vector3.up * mouseX);
    }
}
```?
#

this maybe

#

OH MY

#

THE CODE

#

WORKED

rigid island
cosmic mica
#

YIPPE

cosmic mica
rigid island
#

notice how the sensitivity is cranked to 100.. thats high because its trying to compensate for wrong calculation

cosmic mica
#

Once a coder said "If it works don't touch it."

rigid island
#

it doesn't work properly though, you just arent noticing at this framrate but others will

mossy flare
rigid island
cosmic mica
#

ohh

#

how do i fix it

mossy flare
compact spire
#

So, currently I'm importing the stateless plugin to handle all of my state machines in my projects. Is this going to bite me eventually? Are there some other efficient methods of setting up state machines that I don't have to build from scratch?

rigid island
cosmic mica
#

just del?

rigid island
#

the sensitivity needs to be changed back to a reasonable number

cosmic mica
cosmic mica
#

I added animations now yas

still sparrow
#

Could anyone help with a script error question? Im using Unity 6000.0.39f1 and Im using Gaia Pro VS and I added Crest 4 (the latest update) and Its putting out a script error.

#

Assets\Crest\Crest\Scripts\Integrations\Gaia\GRC_Crest.cs(16,27): error CS0117: 'Object' does not contain a definition for 'FindObjectByType'

naive swallow
somber nacelle
#

the error is pretty self explanatory, there is no method called FindObjectByType on the UnityEngine.Object class, there is an old deprecated FindObjectOfType method, but it has been replaced by FindFirstObjectByType and FindAnyObjectByType. there is a method called FindObjectsByType but that finds multiple objects, not just one

#

also with that being an error in an asset you should report it to the asset developers so they can fix it

still sparrow
#

That makes sense if its already been deprecated. I'll try and replace the older with the newer method and see if it fixes the problem. Thank you for the quick replies!

somber nacelle
#

seems like the asset author probably read about the old FindObjectOfType being deprecated and just changed the name to FindObjectByType without actually making sure that compiled

dim umbra
#

What's the most commonly used approach to have dialogue show the correct button glyph for whatever controller the player happens to be using? I couldn't find any tutorials for this specific thing

fleet gorge
rigid island
fleet gorge
#

you can use a dictionary<keycode, sprite>

dim umbra
fleet gorge
#

oh so you're not storing the keybinds rn

dim umbra
#

was just wondering if there was some common thing on the asset store everyone used

fleet gorge
#

that's what the new Input System is supposed to help with

cosmic mica
#

Yo guys I couldn't sleep because of this one thing

dim umbra
cosmic mica
#

How can I overwrite the animation to ik

dim umbra
#

does it have this built in?

fleet gorge
#

for me I use old input manager and made my own input system, from there I can access the keycode of the action I want

My system came with its own saving of keybinds

cosmic mica
#

Whenever the anim starts playing the ik stops functioning

dense rock
#

Hey there, can somebody give me some advice on how bootstrapper scenes are usually handled in unity? Idk how to do it and can't really trust ChatGPT. Do I just put some important objects/singletons there and make them Don'tDestroyOnLoad, or do I load all other scenes Additively? I tried it like in the screenshot, but that seems weird because multiple EventSystems and also the UI in the DDOL Scene doesn't display at all.

lean sail
dense rock
stable osprey
#

Might wanna use prefabs instead of scenes (?) nest as needed

ocean hollow
#

what in the world is going on here. i have my using tags and i dont have a custom CharacterController class.

dense rock
oblique spoke
ocean hollow
#

oh whoops, i do have a custom character controller class after all 😅

stable osprey
#

In this case, simplest is a script that spawns the UI manager once and adds it to DontDestroyOnLoad scene

#

Try

[RuntimeInitializeOnLoad]
static void Init() {
    var prefab = Resources.Load<UIManager>(“UI Manager”);
    // instantiate
    // DontDestroyOnLoad it
}
dense rock
#

ah interesting, I'll look into it

#

thanks ^^

lone turret
#

Anyone know what I'm doing wrong? I'm attempting to create a copy of a read-only atlas-texture-region onto another texture. I've tried Blit-ing it, copying it, loading the bytes, but I can't get it to work. I feel like it should be just this easy

#

but that ends up with a weird squished result of horizontal lines rather than the sprite I want

dense rock
#

okay sorry for the ping, I finally found that the sort order is on the canvas and not another component

stable osprey
#

Yeah you can set depth on UI canvases to decide their order. On non-URP projects at least

zinc tartan
#

im trying to move an object relative to another as if it were parented to the other object because in my case i just cannot parent it, how would i go about this?

stable osprey
#

also np for the ping I just have my phone on silent mode and check whenever I’m free 😄

night harness
zinc tartan
night harness
#

yeah that's what it does afaik

zinc tartan
#

it freezes the position of the object and if you unfreeze the position the object wont move with the source

rigid island
latent latch
#

kinda. Sometimes I do want to inherit position but not the rotation

#

just give me a damn bool unity

night harness
#

position constraint go brrr

kind cobalt
#

hey fellers anyone know how i can change the color of an emission by pressing a key? kinda new to scripting and im trying to have a light effect for this hover car whenever it moves

#

i heard color lerp is good but not too sure how to apply that

cosmic rain
#

So you'd set the material emission color to change it.

kind cobalt
cosmic rain
atomic whale
#

what would be the performance difference between Graphics.RenderMeshInstanced and creating the whole thing as one mesh at runtime?

cosmic rain
atomic whale
kind cobalt
#

hey so im still figuring this stuff out but im trying to gradually change an emission color by pressing a key and then having it gradually return to the original color when releasing the key, is this looking correct or am i just completly off?

cosmic rain
cosmic rain
mellow sigil
#

Well it's "fine" for a first draft at least. It still needs quite a lot of work in addition to that

kind cobalt
cosmic rain
kind cobalt
#

yeah

#

just wanted to make sure it wasnt just me

cosmic rain
#

Then you should know what and when it changes

kind cobalt
#

anyway i can make it revert? would i just use else then just reverse it? im guessing theres a better way to do that

cosmic rain
kind cobalt
#

would that be getkeydown?

cosmic rain
#

Yes. Read the docs.

kind cobalt
#

yeah ive been reading them just a bit weird learning how to piece it all together

mellow sigil
#

The logic should be that if a key is being pressed, current moves towards the max value. Else it moves towards the min value. At the end set the emission to the current value.

#

Getkeydown is not the right one if you want to check a key being held

pastel patio
#

Hi guys, how would you handle having a bunch of different things to initialize in your game?
There is the AssetManager, the Dimension preset, the Generators, the different parts of the gameloop and so on...

The best I can think of would be using either execution order or making 1 script call the initialization for all the other scripts, though I'd like to know if there're any other solutions/tips on this matter?

night harness
#

One script to handle the initial order is totally valid but also from what ive seen its generally pretty fine to explicitly define order of execution for your manager esque classes

pastel patio
#

Of course, to block the possibility of "Looped initialization", each will also have an in-between state of "Initializing" that would throw an error if initialization is attempted while it's busy initializing.

kind cobalt
#

hey so messed around and made this, the problem is instead of the color changing gradually its instant any idea why or am i just dumb and missing something important?

mellow sigil
young yacht
#

you have newColor and oldColor

#

try using one variable instead

#

never used Color.Lerp() before so not sure

kind cobalt
kind cobalt
#

I HAVE NO IDEA BUT ILL TAKE IT

#

for some reason it would only get darker but not brighter

#

and i dont even know what i did to fix it

#

but its fixed

#

ill take it

#

ah

#

so it turns out unity discards the emission color if it starts out as black

#

so yeah

#

awesome

elfin quest
#

Hi everyone

If I have a scene that is UI only (with UI Toolkit) I don't want any cameras since it's rendered in sceen overlay. Can I disable the Display X no cameras rendering? Is the solution really to add a camera even if I'm not using it?

latent latch
#

Generally I would anyway and instantiate the cameras background black just in case some pixels don't get initialized by having some UI space not rendered

elfin quest
woeful hamlet
#

How do I use a method (with no parameters and no return value) as a variable?
I wanna have a character with a different special action (or no action at all) depending on the level, and instead of checking the level whenever I hit the button, I figured that just setting a variable for the action once at the start of the level was simpler, but I can't get the syntax right.

#
 private specialAction special = () => { Debug.Log("test"); };

...

void Start()
{
    ...
    if (LevelManager.instance.GetLevel() == 2)
    {
        special = Sonar();
    }
}```
#

The part with the lambda expression works, but the last line gives me an error.
"Type 'void' can't implicitly be converted into 'PlayerControls.specialAction'"

lean sail
wintry crescent
#

        private List<(int, TutorialHandPlacement)> hintOrder =
        [
            (2, TutorialHandPlacement.PixelatedView1),
            (4, TutorialHandPlacement.PixelatedView2)
        ];

I'm trying to declare a list of tuples, but this isn't "avaliable in c# 9.0"
how can I achieve what I'm trying to do? Do I have to create it during runtime?

woeful hamlet
vestal arch
wintry crescent
lean sail
#

I think if you start off by doing it by declaring the list then manually adding elements, your ide might give you how to do what you're trying in 1 line. I forgot if that applies here or for other cases

vestal arch
vestal arch
vestal arch
woeful hamlet
low rapids
#

i tried parenting the object on impact but it glitched out and made my other movement code messed up

thorny rock
low rapids
thorny rock
#

You can make a "platform movement script" with a movement speed and movement direction. Then if the ball hits that, get the component and then you know which direction to move and by how many units.

#

Good luck! Pretty cool stuff if you can make that work 🙂

lean sail
vestal arch
lean sail
#

Ah I see what you mean.

chilly surge
heady wolf
#

Hi, I have a created static class with all the events in my game. As now, I add listeners in Start and remove listeners in OnDestroy, but I noticed unity sometimes runs out of memory, so I think I could have caused a leak. It would be a better solution to add listeners in OnEnable and remove in OnDisable? Thank you in advance, have a nice day 😉

lean sail
#

using enable or disable would only matter if you were actually disabling these objects and didnt want to subscribe while they were disabled

vestal arch
vestal arch
thick terrace
thin aurora
#

Unless Unity doesn't use the c# language that supports it

#

Bracket initialization is valid syntax, you don't even need to call the constructor in that case.

#

Please post the thing you need help with

sleek bough
#

!softban 1329015184273965096 spam

tawny elkBOT
#

dynoSuccess butskyi was softbanned.

zinc flax
#

My unity pause when my player is drilling down and I don't see any log about it. I don't know what's happening. Any idea how to solve a problem like this?

#

I haven't touched my drilling script, this problem happen since I modified my terrain generation script. I looked it up and found a potential issue, I fixed it but the problem still occur.

somber nacelle
#

make sure you haven't hidden errors in your console

zinc flax
#

oh I had error pause active

somber nacelle
#

yes, and ideally you would leave that on and fix your errors instead of ignoring them

brave warren
#

Hey! Could someone tell me if my post in #💻┃code-beginner is in the right channel? I'm trying to get some help implementing a feature

soft shard
brave warren
north cypress
#

I need a way that when the charecter takes damage it plays a random voice line -

Idk the best way to ask for this except ask really nicely of anyone can call and go through it with me, and I'll show u what I got and what I wanna try and do.

I'd rlly appreciate some help and idk if this is more of #🔊┃audio thing.

Please let me know

leaden ice
north cypress
leaden ice
#

the point is you run that function when you want to play one of the sounds

north cypress
#

Legend

#

I js add like 15 audio sources to the audio clips then?

leaden ice
#

however many you want

#

it will work with any number as long as there's at least one

north cypress
#

Yk I've been pulling my hair out at this lmao

#

Thanks u legend

stable osprey
#

sorry but I gotta ask.. what exactly have you been pulling your hair about? Like, what did you try and didn't work?

north cypress
stable osprey
#

I see.. yeah it's not an optimal way

#

try to go approach everything with an "AS SIMPLE AS POSSIBLE" mindset next time

#

for example, your data is a bunch of audio clips, so you make an audio clip array

#

then you need some way to pick ONE RANDOM, so you code that method

#

then you need to play it, so you code that method too

north cypress
#

Oh yeah for sure

#

I'm still learning haha 😛

stable osprey
#

I know it just sounded suspicious u shared a problem without any code here.. made me think you just wanted a ready solution lol

north cypress
#

That makes sense, I can try find my old code if u want a gander

stable osprey
#

but the reason I asked is because... ChatGPT would be able to provide this solution, so I got genuinely curious about what your previous approaches were 😄

north cypress
stable osprey
#

AI isn't half bad for education.. before it was as developed as it was now, we used google to get answers for each of our problems (basically learn for it)

north cypress
#

Yeah

stable osprey
#

the "trap" with AI is that one can just keep ASKING for READY CODE instead of learning from it.

#

but as long as it's used as EDUCATIONAL TOOL instead of CODING TOOL it's pretty nice imo

north cypress
#

Yeahahaha

#

True

#

I js wanted humans not AI lmao

stable osprey
#

fair, fair 😄

zinc tartan
rigid island
zinc tartan
north cypress
#

I'm losing the plot

#

How the hell do I call another scripts function in a different script

#

I might be burnt out bro

#

Cause none of these online forums are working

leaden ice
north cypress
#

That's what am tryna do

leaden ice
#

I'm sure all the things you are looking up work fine.
Show what you are trying and what's going wrong

north cypress
#

Sure sure

#

Are you able to call real quick

leaden ice
#

no

north cypress
#

So I can screen share ?

#

Okay no worries

leaden ice
#

share screenshots and code here

#

make a thread if you need to. This is an extremely basic part of Unity that beginners always struggle with but I've helped people with hundreds of times.

north cypress
#

So discord on my PC is freaking out lmao

vestal arch
north cypress
#

that worked ty

#

then i also tried eceyrhting on this thread

leaden ice
#

it would be like

// You need to assign this variable in the inspector
public DeathAudioPlayer audioPlayer;

void SomeFunction() {
  audioPlayer.PlayRandomSound();
}```
#

your code doesn't look like any of the examples

#

Capital P on Public? bad.
No name for your variable? bad.
Trying to call functions outside of a function? bad.

north cypress
#

its tryna send a vid

#

but my disc slow as hell today sr

wheat spade
leaden ice
#

not ever in my experience has it been this way

#

You have to add dependencies your asmdef manually

somber nacelle
#

most packages aren't actually precompiled assemblies

#

precompiled implies dll which packages typically aren't

leaden ice
#

Example from my project

north cypress
#

bruh it will not send this vid

wheat spade
#

Ah. They should specify dll in the docs.

leaden ice
#

I guess maybe it's the word "precompiled" that is the problem here

north cypress
#

can i use my phone camera?

leaden ice
#

why do we need a video

#

show code and screenshots

north cypress
#

js tryna show u code is all

somber nacelle
#

!code

tawny elkBOT
leaden ice
north cypress
#

i cant rlly use that as imma tryna reference another script tho

#

it wont even send ss what is my life bro

vestal arch
vestal arch
#

if your computer has a poor connection

north cypress
vestal arch
#

code is best shared through text (via one of the 2 above methods)

north cypress
vestal arch
#

!screenshots

tawny elkBOT
#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

vestal arch
#

what namespace is DeathAudioPlayer in?

north cypress
#

im tryna sue pastebin i thinkmy pc crashikng tf out lmao, lemme check chris rq

somber nacelle
#

prefer one of the sites that the bot linked, pastebin sucks

vestal arch
#

im pretty sure your pc just has a bad internet connection

leaden ice
#

show the top of that script

north cypress
#

Unity

leaden ice
#

this is also kinda sus

north cypress
leaden ice
north cypress
vestal arch
#

ok so that's unsaved

#

Health.cs was also not saved

north cypress
#

sorry guys im teerricly new to this teehee

leaden ice
#

this is actually the main problem

vestal arch
#

if you're not too familiar with c# yet, maybe don't use namespaces/assemblies. it's a layer of extra complexity

leaden ice
#

one of your scripts is in this fps.Game assembly

#

the other script is in Assembly-CSharp

#

basically you've stepped on a landmine because you're trying to modify/add extra stuff to a sample game project that is using Assembly Definitions which is a concept that is way over your head right now.

north cypress
#

how fo

#

how do i change it's assembly

leaden ice
#

Basically if you move your script into the same folder as that fps.Game stuff it will work

north cypress
#

ahhhhhh i see

leaden ice
north cypress
#

so an assembly is one of the folders inside the main section

leaden ice
#

Like here all my scripts are in the GameAssembly assembly

#

so things in there won't be able to reference things outside of it.

#

In your case the Health script is in the fps.Game assembly so it can't see your DeathAudioPlayer script which is outside

north cypress
#

Legit can't send shi on my pc

#

No clue why

leaden ice
north cypress
#

My PC got full WiFi and I can use Google

steady bobcat
#

MY EYES

north cypress
#

Bro I should be paying u atp

leaden ice
#

you have void PlayRandomSound() it needs to be public void PlayRandomSound()

north cypress
#

That worked

leaden ice
#

by default, all members on a class are private

north cypress
#

U my friend have saved my life today

leaden ice
#

if you put nothing, private is what you get.

north cypress
#

I appreciate it

#

Genuinely man is there anything I can do to repay u lmao, you've spent a lot of time on me today haha:P

vestal arch
#

well since praetor isn't taking it, i'll request you stop using photos of screens period, and stop using screenshots for code please

zinc parrot
#

Hey so if a mesh is not readwriteable
And you make a build with it
Is there ANY way to get the triangle data of that mesh on the cpu in the build?
Since index buffers don’t seem to exist in builds(meaning I can’t do fancy gpu->cpu read back things to transfer the mesh data to the cpu) is there ANY other way?(I cannot gaurentee/force the mesh to be readwrite in the editor or save the mesh seperately in the editor, basically gotta be treated as a mesh that gets “imported” after build that’s not readwrite able)

zinc parrot