#💻┃code-beginner

1 messages · Page 138 of 1

swift crag
#

you will want to assign a reference in the inspector

distant robin
#

hi can someone help me with this script? in this script i basically have an input field which i can type phone numbers in it (and i can configure the numbers in the inspector) the problem is, no matter what number i type it gives me the invalid number audioclip. i also setted up a debug log to tell me which number i typed and it always appear to be blank. sorry for my bad english. can someone explain me this? thanks in advance

https://gdl.space/icojolugis.cs

whole sapphire
swift crag
polar acorn
#

Why do you have a component named ScriptableObject? You shouldn't name scripts the same as unity built in types that's just going to cause problems

swift crag
#

please just read it

whole sapphire
#

yeah i know

buoyant knot
#

like how on most gameconsoles, the console will prompt you with a whole keyboard UI for the console, and then put the string into the game once tou close

swift crag
buoyant knot
#

switch, xbox, ps4, ps5 have it

polar acorn
swift crag
#

I'm not aware of a plugin. I know how I'd do it, though.

buoyant knot
#

a standard UI for the console to bring up a way to input strings

swift crag
#

you'd give a callback to the keyboard and have it appear, then wait for the callback to be run with the string the user provided

whole sapphire
#

Is it a must to do it with tag

buoyant knot
#

no

swift crag
#

no. please read the page you were linked to.

sullen perch
#

hi, im new to unity and im using visual studio but for some reason my errors arent underlined

eternal falconBOT
real thistle
#

Why is that?

swift crag
#

you'll want to follow these instructions

whole sapphire
distant robin
polar acorn
# real thistle Why is that?

You should be able to know immediately at a glance what any line of code does completely removed from any surrounding code.

Var makes it harder to read your code because it requires context to know what type it's supposed to be. Small bits of extra effort to read a line add up over the hundreds or even thousands of hours you spend in a project

twilit pilot
buoyant knot
#

serialize reference is how you set a direct reference to something in the inspector. Singleton is to get access to a specific class of which there is exactly one. GetComponent is to get a specific component on a gameobject once you have a reference to the gameobejct

real thistle
buoyant knot
swift crag
#

I do find it a little "unsatisfying" to read a var line

polar acorn
swift crag
#
var doohickey = GetContraption();
real thistle
languid spire
swift crag
#

obviously I can hover over var to find out that GetContraption returns a Widget

#

but that's a layer of indirection

real thistle
polar acorn
real thistle
swift crag
buoyant knot
languid spire
real thistle
polar acorn
swift crag
#

you are not convincing me of my own stance on var

real thistle
swift crag
buoyant knot
#

but not by looking at your code

real thistle
swift crag
#

i have to stick my cursor on the var to find out what it actually means

real thistle
real thistle
languid spire
buoyant knot
#

foreach (var entry in myList) {

What type is entry? You can’t know based on what I wrote

real thistle
polar acorn
real thistle
slate gale
#

How can I use Quaternion.Lerp() to rotate towards an object's position?

swift crag
real thistle
swift crag
#

that will let you rotate at a constant rate

buoyant knot
#

var makes it worse to read

polar acorn
swift crag
#
transform.rotation = Quaternion.RotateTowards(transform.rotation, goalRotation, Time.deltaTime * 90);
#

this is a 90 degree per second rotation

real thistle
slate gale
#

thx mate

slate gale
#

and then I can just lerp the '90' towards a lower value i guess

meager vault
buoyant knot
#

var makes all code less obvious because you just don’t show the name of the type you are working with IN THE CODE

swift crag
slate gale
#

yeah

real thistle
languid spire
swift crag
slate gale
#

i'm trying to rotate a player camera towards a target

real thistle
polar acorn
# real thistle How does it make it worse?

The many examples you've been given where your only response was "well that's just bad code"

Yeah, it is. And sometimes that happens to the best of programmers, so why make it harder to read bad code

old venture
# languid spire yes, at compile time but not when you read it

In the majority of places the specific sizes of types dont matter. It's the "shape" of a type that determines the logic of the code.

I would agree with using explicit type names in networking or any form of binary serialize adjacent code... but general code, nope

swift crag
#
float closeness = Mathf.InverseLerp(0, 180, Quaternion.Angle(transform.rotation, goalRotation));
float rate = Mathf.Lerp(30, 180, closeness);
transform.rotation = Quaternion.RotateTowards(transform.rotation, goalRotation, rate * Time.deltaTime);
meager vault
polar acorn
swift crag
#

This will rotate at 180 degrees per second at the maximum angle and 30 degrees per second at the minimum angle

real thistle
versed sail
#

Let's imagine if you have some code like:

var z = x.FirstOrDefault(y => y.Name == z);

How are you supposed to read this code?
Simply you can't, you have to go back up your previous code and look at what x/y/z are:

IEnumerable<User> x = ...;
string z = ...;

But that's the thing: if your code is so unreadable that you have to commit to memory "x is an IEnumerable<User> and z is a string" just to be able to understand what it does, at that point it's not even about your type anymore.
If you just properly name your variables, it literally does not matter what the types are:

var foundUser = users.FirstOrDefault(user => user.Name == targetName);

Does it matter if users is IEnumerable<User> or User[] or List<User>? Nope, you absolutely can still understand what that piece of code does.

swift crag
old venture
polar acorn
buoyant knot
swift crag
versed sail
#

If you have to commit to memory "x variable is of type Y" just to read the code, you are already on the wrong path.

distant robin
old venture
#

If anything, var forces people to write better.

meager vault
polar acorn
languid spire
real thistle
swift crag
#

we're bringing back Hungarian notation!

polar acorn
real thistle
#

This is not "use the type or specify the type in the variable name", it's a bit silly to assume that.

versed sail
meager vault
#

That's the rest of the team's fault for letting it through.

languid spire
versed sail
#

users gives enough information with context, you don't need to name your variable aListOfUsers.

swift crag
#

of course you shouldn't write bad code

buoyant knot
old venture
buoyant knot
#

this way, I just know my variable’s type, because every variable has the type in its name….

swift crag
#

even when the imperfect human beings creating those things make mistakes

polar acorn
# meager vault It should've been caught at the PR level.

Yes, the Magical Christmas Land scenario where everything is named perfectly and all code is reviewed var is fine but in an actual pragmatic case where you deal with brain farts, undercaffeination and just plain bad decisions it makes things harder to read and using an explicit type doesn't make good code any worse so why not just use it from the get-go?

twilit pilot
#
List<string> list = /* .. */
var orderedList = list.Select(element =>
    {
        if (!int.TryParse(Regex.Match(element, "\\d+").Value, out int index))
        {
            index = 0;
        }

        return (element, index);
    })
    .OrderBy(pair => pair.index)
    .Select(pair => pair.element)
    .ToList();

what type is orderedList?

languid spire
slate gale
#

why would you use var if you could just use the datatype of what it's actually gonna be

#

just seems more complicated imo

old venture
#

@languid spire replace std::string with const char* there and it's c

#

Exact same thing

swift crag
meager vault
# swift crag "just don't write bad code" is a meaningless take

It's not meaningless; you stated that bad code made it in the system. That means someone didn't do their job. If you need the type explicitly on the line as you're fixing their mistakes then you don't know how to use the tools at your disposal and should use that as a learning experience for yourself.

versed sail
swift crag
#
var target = Quaternion.LookRotation(direction);
transform.rotation = target;

(contrived example, yes)

real thistle
slate gale
swift crag
whole sapphire
#

i now only know creating a script is like creating a class

#

bruh'

buoyant knot
languid spire
real thistle
summer stump
versed sail
polar acorn
buoyant knot
#

in that code, if you use var, it is not immediately obvious that the timeEntry is a TimeSpan vs a float vs int

languid spire
versed sail
buoyant knot
#

but you do not know if the entry is a timespan or a float without writing it out. Which gives access to different methods

real thistle
swift crag
#

that's not even the right fallacy

old venture
#

As are plenty of us UnityChanHuh

buoyant knot
#

you can only really justify var once your type names are very long

swift crag
#

the point that's being missed here is that more information helps.

you can infer the meaning of something with incomplete information, yes, but why not have more information?

meager vault
# polar acorn Yes, the Magical Christmas Land scenario where everything is named perfectly and...

In a pragmatic case, I expect developers to be giving their members meaningful names, that's not magical Christmas land where everything's perfect; that's a standard where I work now, and everywhere else I've worked. To be clear, I'm not against using explicit types, but I'm not hard against using var, and I don't think anyone should have an arbitrary rule against something that's useful when used properly.

Sure, I can harm myself or others if I play with a nail gun, but used properly it saves time.

swift crag
#

especially when you are working with something you're unfamiliar with

restive tiger
old venture
#

Code Lens and similar in VS helps with the unfamiliar code

languid spire
old venture
#

It lets you optionally display the typenames inline

real thistle
versed sail
buoyant knot
#

if I have HashSet<FixedSpawnpointHandler<TilePlacementSingle, CircleCollider2D>>, then yes write var so you can see what you are doing

swift crag
buoyant knot
#

heretics must be purged

versed sail
meager vault
queen adder
languid spire
buoyant knot
#

still not obvious in your “correct” example

real thistle
meager vault
buoyant knot
#

declaring a variable type doesn’t normally affect the line you declare it. it affects the following lines where you USE it

sinful sun
#

just make a pr with for (var i=0; i < 10; i++) if you want a lazy friday

swift crag
#

i'm more of a ++i sort of fellow

swift crag
#

i'm not a huge fan of how several people joined exclusively to argue in a holy war about a keyword

summer stump
sinful sun
swift crag
#

this is taking up a huge amount of space in a chat for Unity beginners

meager vault
ivory bobcat
twilit pilot
versed sail
fickle plume
#

If you want to continue discussing this create a thread

ivory bobcat
#

One's definitely more explicit though.

sinful sun
real thistle
whole sapphire
#

how do i do sth to all object containing a tag

swift crag
whole sapphire
#

for example

swift crag
#

This might be the best option, but there also might be a smarter way.

whole sapphire
#

make all maps dissapear

twilit pilot
whole sapphire
#

unactive

real thistle
swift crag
#

this has been amazing. i've written 0 lines of code so far today

swift crag
whole sapphire
#

well thats just a name

ivory bobcat
whole sapphire
#

all of them have a tag called 'maps'

whole sapphire
gaunt ice
#

learn what is loop

swift crag
whole sapphire
#

do i need to loop through them or what

ivory bobcat
swift crag
#

It will give you an array of GameObject you can iterate over

ivory bobcat
#

What's the actual issue?

swift crag
#

I'm still unsure if this is the best way to do what you want, though.

whole sapphire
#

i think it is

swift crag
ivory bobcat
#

How to manage a group of types? How to find a group of types? How to iterate a group of types? What?

swift crag
#

tell me what's happening from the player's point of view.

whole sapphire
#

basically

#

i want the map to change

#

my way is like hide all the map and show a new one

split dragon
#

Hi. I have a question about optimization: if scrolling with the mouse wheel and the fact that the camera field is less than 40, how should I set it correctly so that it is better? Or will nothing change from their arrangement?

swift crag
#

the second map's objects would all have to be tagged "Map 2" or something

#

It sounds like you want to just load a different scene.

whole sapphire
#

nah

#

i think my way will work

ivory bobcat
# whole sapphire i want the map to change

When might be important so that we know what you've got access to. If at any time, you may need a manager else someone needs to pass reference to the collection of "maps" or you'll have to search the hierarchy etc

swift crag
#

It'll zoom super-fast on a macbook trackpad, which sends a lot of tiny scrolls

split dragon
swift crag
#

deltaTime is not appropriate here.

#

Input.mouseScrollDelta.y is a distance -- how far you've scrolled

#

If you scroll by a certain amount, the camera should zoom by that amount

split dragon
gaunt ice
#

this is not optimization (at least to me)
you ++ and -- no matter what the magnitude is

swift crag
#

"an example of time"?

split dragon
#

In short, should I write if mouse scrolling first, and if camera restrictions second, or vice versa? Or will nothing change from their location (about what would be better for optimization)?

swift crag
#

Ah, I see what you are asking.

#

It should not matter at all. However, I think the way you wrote it makes more sense.

whole sapphire
#

eh why are the brackets in red

swift crag
#

You have a syntax error.

#

Something is wrong with the public void changeMap(... line, most likewly.

whole sapphire
#

theres a semi colon at the b ack tho

swift crag
#

That's incorrect!

whole sapphire
#

i mean the line

swift crag
#

you don't just use semicolons everywhere

#

A semicolon ends the current statement. It's like the period at the end of a sentence.

whole sapphire
#

yes i know

swift crag
#

The syntax for a method declaration looks like this

whole sapphire
#

i mean the inside code

swift crag
#

Ah, okay

summer stump
swift crag
#

just show all of the code please

whole sapphire
summer stump
#

Private inside changemap

swift crag
#

we can't see your screen, so we can't tell you what's wrong

whole sapphire
#
public class flowManagerScript : MonoBehaviour
{
    public GameObject mapListFolder;
    // Start is called before the first frame update
    public void changeMap(string map)
    {
        private Array mapList = GameObject.FindGameObjectsWithTag("Maps");
    }
}
swift crag
#

Ah, interesting, the compile error winds up there

summer stump
#

You can't write private/public/etc inside methods

languid spire
#

private Array mapList = GameObject.FindGameObjectsWithTag("Maps");

swift crag
#

so, yes, as Aeth said, access modifiers -- private, public, etc. -- are only used when declaring the members of a class

whole sapphire
#

oh right that fix it

#

thanks

swift crag
#

Members are things you declare directly inside of the class

ivory bobcat
swift crag
#

I'm a little surprised the error was on the {. I guess the compiler saw the private and then decided the prior { was bogus?

swift crag
#
fov = Mathf.Clamp(fov + Input.mouseScrollDelta.y, 5, 40);

^ it'd look like this

#

You may need to divide the delta by something

#

to slow it down

buoyant knot
#

you can already open the profile to see what my base username is anyway

deep robin
#

How do i use a power function with the short datatype?

hexed terrace
#

Your VS isn't configured to work with Unity correctly.. sort it out !vs

#

!vs

eternal falconBOT
#
Visual Studio guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

hexed terrace
#

@deep robin ^

twilit pilot
buoyant knot
#

are they arguing right now about var lmao

languid spire
deep robin
#

Thanks @hexed terrace. I got that sorted out. Anyway, I still have this problem.

clever mica
#

I'm tempted to ask what's the generally take about #region in C# then if I see this

#

but I fear to wake up another dinosaur

#

🙃

ivory bobcat
deep robin
swift crag
#

why are you using short?

#

you can just bit-shift if you want powers of two

deep robin
#

@clever mica What do you mean?
@swift crag I don't plan on having the values be any bigger, I should really make them constants.

swift crag
#
short microUnit = 1 << 3;
short macroUnit = 1 << 6;

alternatively, multiply microUnit by itself. C# doesn't offer those math functions for integral types

languid spire
#

should be byte anyway (just being picky)

split dragon
clever mica
#

I did not except to see that

twilit pilot
split dragon
clever mica
#

yeah, bit more than 90% but yeah

swift crag
deep robin
#

@twilit pilot How's it obnoxious and unneccasary? I like to #region EVERYTHING.

languid spire
#

in the days when we worked with 15" monospaced monitors or even 800x640 resolution #region was usefull, today? Nah

mighty axle
#

just put it in another file

#

thats what i do

swift crag
#

I'm very happy with being able to jump to definitions (either locally in the file, or across the whole project)

mighty axle
#

private methods take up too much space so i usually make a new class and then copy the private method and make it public instead

swift crag
#

🤔

gaunt ice
#

partial class

mighty axle
#

no not partial class

ivory bobcat
clever mica
swift crag
#

i don't think i could handle a CSS holy war in here

mighty axle
#

what do you have against monospaced fonts, mr TeBeCo?

buoyant knot
#

that C# discord is on fire discussing var

languid spire
twilit pilot
deep robin
#

@ivory bobcat "less static"? I see them as like folders. The more you have more organized everything is.

clever mica
#

👍

#

thx

buoyant knot
swift crag
#

what's the type? i dunno man, i'm just a dog

clever mica
#

na you want DynamicObject for that

#

dynamic is the cool kid

ivory bobcat
swift crag
#

Hey that's kind of cool actually

#

I still have written zero lines of code today

#

ok time to work

deep robin
#

@twilit pilot No, I actually see zero problem. If you nest the regions seperately from how you nest everything else you can make things quite deep and it only makes everything more manageable.

clever mica
buoyant knot
#

omg i’m stoking the var flames right now

#

it’s glorious

clever mica
frosty hound
#

@buoyant knot So keep it there, we don't need to bring it back here. Thanks.

buoyant knot
frosty hound
#

Apparently not if you keep trying to bring it up

buoyant knot
#

sorry. I’m done here with it

twilit pilot
queen adder
#

Russian dolls is actually a great example lmao

#

You can collapse functions anyway in Visual studio so I never really saw the point of # region

clever mica
#

put every for of issue inside

#

code design / code split / god object / bad code / hidden code

deep robin
#

@clever mica I've actually found a scenario to make regions in input braces. Unfortunately that functionality doesn't exist, at least in G.M.L. Hovering your mouse over the region also seems to help. I'm actually only thinking about using Unity just cause Game Maker Studio's regions don't work concsistently when you use them too much. Some regions just don't close as some sort of bug.

clever mica
#

it's like creating a folder named Utils

queen adder
#

GamemakerUnityChanHuh UnityChanHuh UnityChanHuh

#

Ban this baka

#

Jk jk

frosty hound
#

This isn't Unity related anymore. Make a thread if you want to debate regions.

queen adder
#

Sorry

#

I'll move on

deep robin
#

I'm just talking about my use of regions, it's not about game maker.

queen adder
#

Yeah but this channel is intended for helping ppl not really long code debates

frosty hound
#

Sure, then:

ivory bobcat
# deep robin <@335967437315112961> "less static"? I see them as like folders. The more you ha...

The file structure is robust and can make things easier to read but maybe a bit less structuring can make things more legible. Not saying you can't or shouldn't do something in a particular way that you feel is good but why you might see others have suggestions related to being pragmatic
https://youtu.be/-AQfQFcXac8?si=UpV90qvq5Q_uNphK

Put down the keyboard!

There is nothing worse that using code that has been written to some arbitrary set of standards in the guise of professionalism. Often due to inexperience, or the urge to just keep on trucking, some coders make a complete mess of otherwise perfectly acceptable code.

Source Code: https://github.com/OneLoneCoder/videos/blo...

▶ Play video
ionic zephyr
#

Hi, could someone help me explaining to me what a tick (in terms of Unity) means exactly?

buoyant knot
#

tbf, I just finished adding a combination of 7 different classes and interfaces to my project, to support moving the starting position of a level.

queen adder
#

Programmers put down the keyboard UnityChanHuh lmao. That guy has an amazing C++ tutorial on game engines

buoyant knot
ivory bobcat
queen adder
#

I think he means fps but I could be wrong

deep robin
#

Ok, where would I go to continue this? Not to mention, if someone could tell me how to use a power function with a short that's what I originally came here for. @ivory bobcat, easier to read means more legible. What do you mean? I could continue talking about the benefits of regions but I don't think this's the place for it.

queen adder
#

Frames per second

ionic zephyr
queen adder
#

I think he means tick as in one frame

ivory bobcat
rare basin
deep robin
#

@ivory bobcat, do you know the code to turn my eight into 64 with those cause I didn't even use those in G.M.L.

polar acorn
deep robin
#

@ivory bobcat, sounds interesting. You said there was a third way? The first was to multiply microUnit by itself.

polar acorn
stuck palm
#

does this save the values or a reference to the transform?

deep robin
#

@polar acorn, how do I cast it back to short?

polar acorn
deep robin
#

I guess I don't know how to cast cause the example I looked up looked like a way I've already tried.

polar acorn
languid spire
#

(TypeIWantToCastTo)

polar acorn
stuck palm
polar acorn
stuck palm
#

cus i remember trying to save a transform in a variable and people said it was a bad idea

deep robin
#

Can I juse get code?

polar acorn
stuck palm
#

interesting thank you

ivory bobcat
deep robin
#

Isn't log supposed to be the inverse of pow? Anyway I think I figured out how to cast it.

rare basin
#

depends on what do you want to do with it

stuck palm
safe root
#

How can I get a postion of a object and convert it to a vector 3? This object does move constantly

cosmic quail
wintry quarry
#

sqrt is the same as the pow function

#

just with an exponent less than 1

#

sqrt is x ^ (1/2)

#

log is the inverse of exponentiation

gaunt ice
#

sqrt is inverse of square
log is inverse of pow
a^b=x, log(x)/log(a)=b

cosmic quail
wintry quarry
#

sure. x^2 * x^(1/2) = x

toxic latch
#

So if you have a script that instantiates items from prefabs, how do you change which prefab is 'loaded' in that serialized field at runtime? Like I can drag and drop different prefabs into that field in the inspector, but how would I do so from within a script when I want to instantiate a different item?

polar acorn
#

However you want to get that "something else". From Resources, from a different class, from a list

#

just change which prefab that variable holds

safe root
#

How do I have my Line Render connect to a object? Cause right now it just goes up instead of at the object I click at

polar acorn
swift crag
swift crag
#

or have a list of prefabs

polar acorn
swift crag
safe root
open moss
#

is there a way to have serialized private attributes be non editable in the inspector?
Kinda like how you can't change the script attribute in a component

swift crag
#

Not baked-in. I've definitely seen [ReadOnly] attributes before.

#

You'd have to write a custom property drawer.

timber tide
#

it's actually 2 lines of code in a custom attribute if you wanna make one

timber tide
#

but yeah naughtyattributes will do it for you

sacred egret
wintry quarry
#

presumably, a different copy of the script is causing the error

polar acorn
sacred egret
#

yeah it seems i accidentaly put the script on the Ui too and didnt asign anything

west sonnet
#

Hey everyone. Need some help. I'm trying to make it so that when the player shoots, the gun will push the player backwards a bit. I've got it kinda working, it's just that the force ends abruptly, rather than naturally tapering off. Can anyone help me figure out how to achieve this please?

wintry quarry
#

you are completely overwriting the existing velocity to your desired velocity here

west sonnet
#

SHould I put that in Update()?

wintry quarry
#

so the force will only get to affect the velocity for a single FixedUpdate frame

#

no

#

Update won't help

#

you are missing the point

polar acorn
west sonnet
#

I think I get it. The force is only being applied for a single FixedUpdate Frame. Then it gets overwritten

ivory bobcat
#

You should add to it rather than assign velocity a fixed value if you're not wanting the previous value to be loss

west sonnet
#

but how could I stop it from getting overwritten until the force is at 0?

ivory bobcat
#

velocity += right * horizontal * speed

#

Right refers to the direction

ivory bobcat
polar acorn
west sonnet
#

Sorry 😬

ivory bobcat
swift crag
#

here you go buddy! [prints]

west sonnet
#

Why can't I use forceDir in my FixedUpdate()? It was created in Update. Both Update and FixedUpdate just have void, no public or private

#

forceDir is my direction, right?

ivory bobcat
#

It doesn't exist in the other function

languid spire
#

forceDir is a local varaible to the Update method

west sonnet
#

how can I get it to be used outside of Update?

languid spire
#

don't make it local

ivory bobcat
#

It's declared here

west sonnet
#

Would I have to declared it at the top of my script?

#

It worked :0

ivory bobcat
#

Or declare/evaluate it again in Fixed Update since it isn't anything specific to Update

languid spire
#

why do you not know this?

west sonnet
languid spire
#

well time to learn some c# basics then

west sonnet
#

I wrote rb.velocity += forceDir * Horizontal * speed; in FixedUpdate() but now I can't move my player and if I shoot, the player won't stop moving backwards

ivory bobcat
languid spire
#

AI Generated code or pure copy/paste?

ivory bobcat
#

Pretty sure the code was related to your horizontal movement from input

safe root
#

Why ain't my LineRender going where it should. When I aim at a object and click to grapple to it. The grapple seems to go above where it should be.

eternal falconBOT
ivory bobcat
west sonnet
safe root
west sonnet
#

Also, Transform.Right is Vector3 but I'm using Vector2

ivory bobcat
ivory bobcat
#

(Vector2)rb.transform.right

ivory bobcat
polar acorn
polar acorn
safe root
#

Didn't know it was a option that need to be put on

west sonnet
ivory bobcat
ivory bobcat
primal hamlet
#

hey guys, did someone used Netcode for multiplayer ?

blazing prairie
#

how do I make a reorderable vertical scroll view in unity so that user can reoder the items easily and which works with android to

west sonnet
polar acorn
primal hamlet
ivory bobcat
polar acorn
primal hamlet
ivory bobcat
#

Direction was incorrect in fixed update for movement. I did not click the link but according to blue, your original velocity assignment was #💻┃code-beginner message @west sonnet

west sonnet
#

Wait, I've commented out that line in FixedUpdate() rb.velocity = new Vector2(Horizontal * speed, rb.velocity.y);

ivory bobcat
#

The velocity assignment = was the issue

#

Not your shooting kicking back.

wanton hearth
#

Hi, have a question about some unexpected transform positioning behavior that's really confusing me.

I'm making a meter/timeline:

  • I have a StartMarker at localPos (0, 0, 0) and EndMarker localPos (1, 0, 0)
  • Also have a CursorParent object at localPos (0, 0. 0) that is a **sibling **of StartMarker and EndMarker.
  • If I move the CursorParent to (1, 0, 0), all the cursors line up exactly with EndMarker
  • The unexpected bit: When I move an individual cursor (child of CursorParent), **its local x pos is 1.6 before it lines up with EndMarker. **
  • All the cursors are at localPos (0, 0, 0), lining up exactly with CursorParent, and the pivot point is the same, so
    what would cause this discrepency? The rotations on all mentioned objects are (0, 0, 0), so I don't think it's that?
ivory bobcat
carmine elbow
#

Hey Ho! I have 2 types of Projectiles, one that shoots at a direction and one that shoots towards a position and acts once it gets there, from there on out many more types come out (For example a sniper as normal projectile and a rocket as targeted projectile) I have thought about using abstract classes, but the only thing the projectiles have in common are that they come from an owner and do an action once interacted with. Maybe interfaces work better with this but I am just unsure, would appreciate it if any of you could help me on this!

polar acorn
polar acorn
# wanton hearth Yes

That will affect the coordinate system of any of the children which means their local positions are not going to perfectly align to the position grid of world space

west sonnet
wanton hearth
west sonnet
ivory bobcat
#

You cannot use that line of code with what you're wanting to do.

west sonnet
#

I have but my player still can't move and the recoil force never disappears

ivory bobcat
#

Move line 59 to line 72

modest dust
west sonnet
ivory bobcat
ivory bobcat
#

To not overwrite velocity

west sonnet
#

I want the force to slowly go down to 0, so the player stops moving backwards naturally

#

Yeah

safe root
#

How do I move the LineRender to where I want to be? It keeps spawning at the render instead of the object I set for it to spawn

polar acorn
west sonnet
#

Like, if you shot a big gun, you wouldn't keep moving back forever

polar acorn
#

You can assume "world" is an object with an identity transform (0,0,0 position, 0,0,0 euler angles, and 1,1,1 scale)

ivory bobcat
#

And the movement isn't enough to stop the shot force.

safe root
ivory bobcat
polar acorn
#

All movement results in changes to world position

polar acorn
#

even if you do the move through local position, the end result is the world position is different

west sonnet
ivory bobcat
west sonnet
#

Yeah

safe root
polar acorn
#

position is world space

safe root
polar acorn
west sonnet
safe root
polar acorn
# safe root On the LineRender?

A line renderer only has one kind of position, it is either always local or always world depending on the checkbox in the inspector

safe root
polar acorn
#

Modifying the positions of a Line Renderer depends on whether that line renderer is set to use local or world space

safe root
polar acorn
safe root
#

By making it equal it's postion

polar acorn
eternal falconBOT
polar acorn
safe root
polar acorn
safe root
polar acorn
#

Which looks like it's used to determine the position to spawn a copy of the Rope object at

#

So Rope will always be at the position of PlayerRope when it spawns

safe root
#

But it doesn't do that

polar acorn
#

The clone of Rope is at the whatever position PlayerRope currently is whenever it is spawned

safe root
#

Hold on

polar acorn
rich ember
#

How do i upload code again?

safe root
safe root
#

Well the arrow does

#

But not the render

polar acorn
#

The transforms of two of them

west sonnet
#

!code

safe root
eternal falconBOT
polar acorn
#

Why did you use the bot and then copy-paste the text from the bot into another message

polar acorn
#

Pretty sure those aren't the same numbers

safe root
rich ember
safe root
#

They are the same

polar acorn
#

Nothing in your code even touches these clones beyond creating them

rich ember
#

ok so here is my code and RB. My character starts spinning as if his rotation had velocity after colliding with something. What do I need to change?

safe root
ivory bobcat
#

You can verify by looking at the inspector values for rotation

safe root
polar acorn
#

The index is which point you want to change

warm anvil
#

anyone here familiar with Unity's rule tile pretty well?

safe root
polar acorn
#

It's an int

ivory bobcat
#

The index is the point

polar acorn
#

And it's not a position

#

It's an index. That's why it's called index

safe root
ivory bobcat
#

A line has multiple points. The index would refer to which point - first, second, third etc.

polar acorn
safe root
polar acorn
ivory bobcat
#

Which part of the function are you having issues with?

#

What have you tried?

#

If you're getting the signature wrong, you'll need to look at the docs.

rich ember
#

@ivory bobcat man I am trying to test what you said but I can't for the life of me recreate it now... I am not sure if maybe it just loaded improperly or what lol. thanks for the help anyway

safe root
ivory bobcat
polar acorn
#

Did you look at the link at all

ivory bobcat
#

Did you read the docs?

safe root
#

I know I can put in multiple number but how do those number make it spawn on my character?

polar acorn
ivory bobcat
polar acorn
#

The function I linked you is how you change one of the points in your line renderer

#

set that point to the position of your player

queen adder
#
public static T TryDequeue<T>(this Queue<T> from, System.Func<T> desperateReturn) where T : Component{
        while(from.Count > 0)
        {
            T ret = from.Dequeue();
            if(ret != null)
            {
                ret.gameObject.open();
                return ret;
            }
        }
        return desperateReturn();
    }
```lol, apparently, I cant use this generic because GameObject's gameObject is not the same thing as Component's gameObject
ivory bobcat
#

This implies you're able to get your characters position

queen adder
#

is there a gameObject interface between the 2 class?... yea nah

safe root
queen adder
#

(hope you still rememeber how this method try to work)

ivory bobcat
paper rover
#

Do rigidbodies update through framerate or deltatime?

paper rover
#

Im running a game where i need specific timestamps through deltatime and not all of it is adding up

queen adder
#

solution is to make a duplicate TryDequeue

ivory bobcat
polar acorn
# queen adder

So it looks like something you're doing is trying to use something of type Component, but you're giving it a GameObject

queen adder
#

that gets a gameobject queue and returns gameobject, but having these two because of not having interface just kinda suck

ivory bobcat
polar acorn
ivory bobcat
warm anvil
#

you all can see my chat, yes?

polar acorn
queen adder
#

even though they are meant to get the same thing

polar acorn
#

The issue is with TryDequeue

ivory bobcat
#

Reference components and not Game Objects

polar acorn
#

it wants something of type Component

#

but you are not giving it one

queen adder
#

this is the solution to make it accept go's as well

#

which si nasty haviong to need a separate method for it special

ivory bobcat
#

Transform or almost anything other than GameObject should work.

polar acorn
#

UnityEngine.Object maybe?

sage mirage
#

Hey, guys! I have a question. I want on my game to play my particle effect when my player jumps with a space button. Can I somehow make that to happen?

queen adder
sage mirage
# polar acorn yes

I was thinking of getting the transform of my player and instantiate the particle but I am not sure if that's correct.

queen adder
swift crag
queen adder
#

i was trying to use MonoBehaviour lol

swift crag
#

(and the solution was, indeed, duplication)

queen adder
#

unity please... just one interface wouldnt hurt that much

#

🥺

polar acorn
#

At least I don't see it on the docs

vernal minnow
#

How can I make time display in a game? I was trying time.datetime and even divided by 1000 just shot it up really quickly

ivory bobcat
queen adder
#

that's weird (docs not having it), prettysure you should be able to do cs gameObject.gameObject.gameObject.gameObject.gameObject.gameObject.gameObject.gameObject

polar acorn
vernal minnow
#

Was originally trying for a scoreboard that goes up each second

vernal minnow
swift crag
#

read the documentation

polar acorn
vernal minnow
#

Oh, mb, I didn't realize that was for me

#

Thanks

swift crag
#

This value is undefined during Awake messages and starts after all of these messages are finished.

Huh, that's a new one

ivory bobcat
#

If you're needing time between two instances and not the entire life of the current process, cache the time (current at that moment) and subtract from the current time when you're needing the score to acquire the elapsed time between the two points.cs score = Time.time - startTime;

swift crag
#

i presume that's during the initial Awake messages on the first scene load

green island
#

i have a Interface for attacks and an scriptible object for characters and i want to save there an script for the attack to later then add the script to the player
I tried cs public IAttack attack; but i cant set it

ivory bobcat
#

And what's an IAttack? (Obviously an interface but there's no concrete type)

ivory bobcat
#

Don't recall if it'll work or not

swift crag
#

[SerializeReference] won't provide an inspector UI for you automatically

eternal needle
#

SerializeReference I think you need custom inspector stuff to set it

ivory bobcat
#

Ah bummer

swift crag
#

Although I've only used it a little -- I haven't made a decent-sized game that depends on it yet

#

So, you know, salt, grains, etc.

timber tide
#

i kinda ditched serializableInterfaces

vernal minnow
#

Yeah time.time keeps freezing my unity 😂

#

I feel like I need to limit it in some way

ivory bobcat
timber tide
#

it would be nice if they were supported but trying to go against Unity for serialization purposes always comes back to bite me

vernal minnow
green island
swift crag
#

the entire script, please. !code

eternal falconBOT
eternal needle
ivory bobcat
# vernal minnow Like /10?

Like if your while loop has dependency on it but because it's used improperly, the evaluated value doesn't ever change.

timber tide
#

interfaces would make a lot of my code cleaner though

eternal needle
ivory bobcat
vernal minnow
swift crag
#

this runs a loop until scorevalue is greater than 10

#

nothing else can happen until this loop terminates

#

scorevalue never changes inside of the loop

vernal minnow
#

Had to slash it out bc it was freezing unity

swift crag
#

unity freezes.

vernal minnow
#

It goes to 10 immediately

ivory bobcat
vernal minnow
#

Well 10.004

swift crag
#

Time doesn't pass while your code is running.

#

Your code must finish before Unity can complete the current frame and start the next frame.

vernal minnow
#

When I load into the game, it's always on 10

#

When it works

#

Or freezes when it doesn't

native flicker
#

I am trying to make some walkable buttons and number 1 and 2 work perfectly (data.cost[0 - 1])
And i don't know why it isnn't working since it should work fine
so i get this error:```
IndexOutOfRangeException: Index was outside the bounds of the array.
Button.OnTriggerEnter (UnityEngine.Collider other) (at Assets/scripts/button.cs:61)

and this is my code
```C#
            if (other.name == "m3")
            {
                if (data.money >= data.cost[2]) //error is on this line
                {
                    data.multi += data.earn[2];
                    data.money -= data.cost[2];
                }
            }```
This is my data script

public class Data
{
public BigDouble money;
public BigDouble[] cost;
public BigDouble[] earn;
public BigDouble multi;
public Data(){
money = 0;
cost = new BigDouble[] {10, 25, 75, 250, 750, 2500, 50000, 250000, 1000000, 15000000};
earn = new BigDouble[] {1, 2, 5, 12, 40, 125, 1500, 6500, 35000, 400000};
multi = 0;
}
}```

swift crag
#

I don't know what you're talking about. Do you mean it starts at 10?

#

as in, scorevalue is set to have a value of 10 in the inspector from the start?

#

because then, yes, the loop will not run at all, and your game won't freeze

#

(as long as the score value is over 10, that is)

native flicker
vernal minnow
#

No, in the update, it changes the scorevalue to 10 before I finish loading into the game

#

It does it way too quickly

#

Even /1000 didn't slow it

swift crag
#

That is not what your code is doing at all.

swift crag
ivory bobcat
swift crag
#

Nothing else can happen until the loop exits.

#

But the loop will never exit if Time.time is <= 10

swift crag
#

Each frame, you use the current time to compute a value

vernal minnow
vernal minnow
queen adder
vernal minnow
#

Is there a way to not show the decimals or round to the hundredth slot?

swift crag
#

string formatting can do that for you

#

$"Score: {scoreValue:N2}"

#

this would round to two decimal places

#

$ makes a string into an interpolated string

vernal minnow
ivory bobcat
# queen adder

Is there a reason why circle prefab is a Game Object and not a Component like Transform?

swift crag
#

you can insert expressions with { braces } and then add format info after a colon

swift crag
#

$"{123.456f:N0}" would render as "123"

queen adder
#

it could be anything (I was even desperate enuff to use MB)

vernal minnow
#

What's the N0 mean?

swift crag
#

N means it's a general number

queen adder
#

number format 0 decimal

swift crag
#

0 means 0 decimal places

#

someone else will have to grab the page with all the format options

#

i'm on my tableeet

vernal minnow
#

Hmn, imma have to play around with that to get used to it

queen adder
#

N0 specificall format numbers to 1,000,000

vernal minnow
#

Pretty cool feature though

queen adder
#

I love N0 lol, fav format haha

vernal minnow
#

Is there a way to show the time in xx:xx:xx format?

ivory bobcat
vernal minnow
bright escarp
#

Hey
i have a code
and It is meant to load 1000 files
and i want that during the code loads all those files
it also make a loading bar
rather than the whole game freezing because the code is not finished

timber tide
deep robin
#

Regions can't be overused, change my mind.

ivory bobcat
#

Never truly completing the update function

buoyant knot
#

#regions are good, but you definitely don’t want to overuse them lmao

vernal minnow
deep robin
#

@buoyant knot, you can't overuse them.

#

I suppose you could use them incorrectly but I don't think there's overusing them if you do. I'd love both sides to elaborate.

ivory bobcat
#

Should probably take that to the !csd as this server is more about Unity where the channel focuses on beginner coding in Unity

eternal falconBOT
deep robin
#

Ok, I mean it could've still been relevant to Unity. The thread's closed.

tacit estuary
#

The Three Commandments of OnTriggerEnter:

  1. Thou Shalt have a 3D Collider on each object
  2. Thou Shalt tick isTrigger on at least one of them
  3. Thou Shalt have a 3D Rigidbody on at least one of them
#

Double check that you have the right components on the player and the ammo item

desert elm
#

hm- how can I only make a unit render for a player only if a certain condition is met?

paper rover
#

Question, is interpolate or extrapolate more accurate?

desert elm
#

GO?

timber tide
#

gameobject

desert elm
#

ah okay

#

so disable Gameobject unless a bool is true

timber tide
#

right, can do it by component too only if you just care about the render component

#

otherwise just flip the gameobject on and off

desert elm
#

oh right yeah I only want to disable the sprite render

native flicker
#

how to check if a certain key has been pressed, for example escape key (Esc)

rocky canyon
#

GetKeyDown activates on the frame u press the key on

queen adder
#

are there an event that catches if any gameObjectis destroyed?

rocky canyon
#

OnDestroy()

queen adder
#

there's no listener only?

native flicker
rocky canyon
polar acorn
ivory bobcat
rocky canyon
#

you could hack together a system for listening for OnDestroy() i guess if that fits ur needs

rocky canyon
#

just to avoid any irritations this is bound to cause lol

buoyant knot
#

@deep robin #region MyFunction #region Docstring for my function ///<summary>Docstring</summary> #endregion #region Declare function private void MyFunction(int x) { #region Declare variables List<int> allValues = new(); #endregion #region Loop for (int i = 0; #region Loop break logic i < 10; #endregion #region Increment index ++i){ #endregion #region inner loop myList.Add(i); #endregion } #endregion #region Assign list this.myList = myList; #endregion } #endregion #endregion

wild cargo
queen adder
#

yea, could be like fun if there's just a single object that catches events too, rather than just a sender version

buoyant knot
#

i’m really proud of enclosing the for loop declaration with 4 separate #region statements

rocky canyon
#

wouldnt figure that'd be very optimized

queen adder
#

particle systems go BRrtrtrtatata

rocky canyon
#

can you collapse nested regions?

buoyant knot
#

yes… as long as you are willing to manually collapse/expand when you reopen one

#

IDE remembers which #regions are collapsed, even if nested in a collapsed one

rocky canyon
#

lol, no Ctrl+ shortcut eh

queen adder
#

CTRL+A, then DLT collapses all

#

into oblivion

#

nested regions are nasty to begin with

rocky canyon
buoyant knot
#

👍

rocky canyon
#

except pinch to zoom

#

its just psuedo implemented atm

buoyant knot
#

now just needs to be more responsive, i think

rocky canyon
#

you think? i added some lerps and slerps for smoothing

#

it was super responsive

#

it would get into a rotational whirlwind lol

buoyant knot
#

it just looked like the first one didn’t respond to mouse

rocky canyon
#

oh no it was just a raycast ripple effect spawning thing

#

the 2nd one is the movement

buoyant knot
#

oh then that is fine

rocky canyon
#

then the dot is just wandering

#

we'll see im setting up Unity Remote here in a bit

buoyant knot
#

main controls I expect:

  1. Double tap to translate,
  2. Drag to pan around a point
  3. Pinch to zoom/unzoom
rocky canyon
#

might feel totally different on the phone

buoyant knot
#

you might also want two finger drag to translate

rocky canyon
#

and for rotations i expect

buoyant knot
#

not sure how that would feel tbh, but it might be worth testing

rocky canyon
#

two fingers can pan, zoom and rotate

#

all at the same time..

#

thats what i commonly see

#

Yesterday I was looking for Inspiration for the type of game i want to make.. and i found Door Kickers (2)

#

looks easy, probably super complicated tho

#

AI movement is always my stall point

#

plus in this game the spline follows the navmeshagents path... as u draw

#

cant even imagine where to begin with a mechanic like that

buoyant knot
#

i would make a game idea before you implement anything

rocky canyon
#

ya, absolutely..

buoyant knot
#

the only way i can imagine the camera being a core gameplay mechanic is with a 3D scavenger hunt thing

#

which might be a unique idea

#

eg a 3D collectathon platformer without the platforming

west sonnet
#

Trying to make a light appear on my gun for a second when the player shoots, but my light is not being enabled when left clicking? Anyone know why? Is it an issue with 2D lights?

polar acorn
polar acorn
west sonnet
#

This script it attached to the particle system which I'm using for bullets

polar acorn
#

and the object it's on is not

west sonnet
#

Omg, you're right

#

I feel so dumb lol

#

Thanks

rocky canyon
#

mechanic might be toggling targetted enemies.

#

like an auto-shooter.. but you have to swap targets according to ur setup/surroundings

#

but its a organic developing situation

true pasture
#

is this bad to run 20 times per frame? I know I shouldn't worry about optimisation very much at the beginning. But I was worried this might be egregious.

#

i condensed lines 24 and 25

slender nymph
true pasture
#

ok yeah, I wasnt gonna optimise it unless it was bad. but definitely did that. Is it bad now?

short hazel
#

Or at least use TryGetComponent<T>(out T) to reduce it to one call

cosmic dagger
#

a GameObject is not a command. that part is confusing already. the list should be of CommandButton type . . .

polar acorn
true pasture
#

oh oops i misplaced totalfill

polar acorn
#

Also why you're incrementing i each time instead of just using myCommandsList.Count at the end

true pasture
#

oh didnt know about that

#

im being dumb

#

i did know about that just didnt connect the dots

slender nymph
#

here we go again

true pasture
#

no reason was just the first draft of it. is one better?

slender nymph
#

no

polar acorn
# true pasture

If totalFill is only used inside of Update why is it a field?

true pasture
#

good point

wanton hearth
#

What would cause the initialization of a C# class to result in 'null' when it inherits from MonoBehaviour, but not when it's a plain C# object?

slender nymph
#

are you doing something silly like calling the constructor for a MonoBehaviour?

wanton hearth
#

It's just MyClass class = new MyClass()

ivory bobcat
slender nymph
ivory bobcat
#

You would use Instantiate instead

slender nymph
#

or AddComponent if you just want to add the component to an existing gameobject

wanton hearth
#

Ahh right. I recently moved from Monobehaviours to C# objects for these custom classes, and then changed it back to Monobehaviour so I could test something on a gameobject

#

I wish you could somehow configure C# classes in editor without them having to be monobehaviours. Although I'm sure there's some valid reason that's not possible, lol

ivory bobcat
slender nymph
#

you can provided the classes are serializable and a serialized field of some monobehaviour

wanton hearth
gusty hazel
#

hi

#

im adding a feature where if an enemy is in range, it stops moving and attacks

#

how would i go about doing this

#

(making it stop)

#
void Update () {
        step = speed * Time.deltaTime;
        if (Vector3.Distance(transform.position, player.position) < 5 ){
            transform.position = Vector3.MoveTowards(transform.position , player.position ,step);
        }
``` this is how i currently handle movement towards player
ivory bobcat
#

Distance formula, collider with circle/sphere check, physics callback etc

verbal dome
#

State machines are useful, you could have a "chasing" state where the enemy just moves to the player

#

Then change to a "ranged attack" state when you are close enough

gusty hazel
desert elm
#

I do not see what this error could be referring too in this line-

short hazel
#

explosionHits was null

#

Did you initialize that variable to a new List<Collider2D>() somewhere?

desert elm
#

I just have-

wintry quarry
desert elm
#

oh its supposed to colliders isnt it

short hazel
#

It works because Collider2D derives from Component, so you can add stuff to it

#

But it's best to use the most concrete type available, if you're going to only store colliders, then yes it should be a list of Collider2D

ionic zephyr
#

How can I make my Vector 3 accesible for all scripts but mantaining its privacy?

desert elm
#

that
looks like a lot of errors I do not understand

short hazel
ionic zephyr
#

Thanks a lot bro

short hazel
#

Then all your other scripts can access Vec and will receive a copy

ionic zephyr
#

thanks a lot again

#

but if that vector changes its value through time, does it have the same alterations in the scripts I use it on?

short hazel
#

Yes, the property evaluates the value of the field and returns it each time it's accessed

ionic zephyr
#

thanks bro

buoyant knot
#

this is very useful because you don't want random scripts to just alter your variables whenever the hell they want

#

whenever you declare a public variable, imagine a public toilet. very good analogy

ionic zephyr
#

Thats the thing, yeah

#

but is it written just like that? with "=>"

buoyant knot
#

and if you want to expose a List or Dictionary as readonly, you can always do:

public IReadOnlyList<int> MyList => myList;```
desert elm
buoyant knot
#

=> is just short for making a lambda expression, which is just like a 1 line function

short hazel
# desert elm that looks like a lot of errors I do not understand

The first one happens when you modify a list while foreaching over it (very illegal).
The second one happens when you destroyed an object, but still try to do things with it in a variable (very illegal too).
The last two are editor errors, and may have caused the first two, or vice-versa.

Select (don't double-click) the first error and it'll show more details.

slender nymph
wanton hearth
#

I'm always confused about the emphasis on setting things to private. If variables are being accessed by other classes in unwanted ways, isn't that your own fault for writing bugs?

slender nymph
#

defensive programming, prevent bugs by just not allowing them in the first place

buoyant knot
#

bool MyFunc(int x) => x > 0;
is the same as
bool MyFunc(int x) { return x > 0; }

slender nymph
#

it's the same operator, yeah. but it's explicity not a lambda expression which is an anonymous method

buoyant knot
#

fair

short hazel
#

Yep look at the stack trace

#

The first two lines are internal code of C#, but the third points to your own code (CodingRaycastTest, line 97)

buoyant knot
#

if I need to modify list as I enumerate through it, I iterate backwards

#

for (int i = myList.Count - 1; i > -1; i++) {
myList.RemoveAt(i);
}

short hazel
#

Two lines above the one you highlighted

ionic zephyr
#

what

#

it doesnt let me use it

short hazel
#

You remove one element from explosionHits, while iterating over it with foreach

buoyant knot
slender nymph
ionic zephyr
#

the vector Im trying to make public

buoyant knot
slender nymph
short hazel
desert elm
ionic zephyr
ionic zephyr
buoyant knot
#

you're just copying the list with the ToList method

short hazel
desert elm
#

yep . . and I for some reason removed it when I copied it

slender nymph
# ionic zephyr

you cannot use a non static value in a field intializer. you could make that a readonly property that just returns _characterMovement.PlayerVelocity instead

buoyant knot
#

we're literally telling you how to do it right, and you are refusing to do it

#

.ToList() is wrong to use here

north kiln
short hazel
# ionic zephyr

Also you forgot to name your field!

private Vector3 = _characterMovement...
               ^ NAME expected here!
slender nymph
#

oh yeah that too

desert elm
slender nymph
# ionic zephyr what?

you can't just say "what". i'm not about to explain that entire message, if you don't understand some part of it then you need to actually ask clarifying questions.
But i'm also not about to explain properties to you again so 🤷‍♂️

desert elm
short hazel
#

So you get your own Transform

desert elm
#

yeah, I am aware
thats why I didn't change it

buoyant knot
#

I'm trying to figure out how to use the internal keyword more.
So let's say I have 420 scripts/classes in main assembly, and a group of 69 scripts/classes in that need special access to each other, and the 420-69 scripts need access to these 69 scripts, and visa versa. Is there any way to break up the 69 scripts into a different assembly? Because that would be cyclic dependency, right?

slender nymph
#

can't have cyclical dependencies, yeah. so if you have two classes that need to reference each other they'd have to be in the same assembly

#

but that may also be an indication that your code is too tightly coupled

buoyant knot
#

so internal keyword is useless, and C# has no way to allow me to set access modifiers like this?

slender nymph
#

internal is basically the same as public but only within the same assembly. other assemblies would not be able to access that

buoyant knot
#

well, I have a singleton LevelBuilder where other scripts need to send requests to in order to change the level. But I want my LevelBuilder to have a whole set of classes where they just talk to each other mostly to actually do the building

swift crag
#

internal does exactly what it says it does: restricts visibility to the same assembly

buoyant knot
#

internal keyword requires you to actually have an assembly that is totally decoupled (in one way or another) from the rest to function

swift crag
#

yes

#

it sounds like you're looking for something like c++'s friend

#

there is no equivalent in C#