#💻┃code-beginner

1 messages · Page 187 of 1

rich adder
#

month and a half is plenty of time

#

unless you're lazy I suppose that makes sense

languid spire
#

spend a month learning and make a game in 2 weeks or spend the next 6 weeks to produce nothing, your choice

carmine sierra
#

i do other subjects not just cs

rich adder
carmine sierra
#

fair

#

need a network and a few sprites

rich adder
#

no you need to understand basic coding concepts if you plan on doing scripts

#

script doesn't do much if you don't even know why a certain method belongs somewhere etc

carmine sierra
#

any videos you would recommend watching, I know python already

rich adder
carmine sierra
#

thanks, does it require me to make a new game though

rich adder
#

no just open a project and start coding

carmine sierra
#

okay thanks alot

rich adder
#

just make sure you at least configure your IDE before doing any coding

carmine sierra
#

like using extensions?

#

I have those

rich adder
#

depends on the editor

carmine sierra
#

also my cs teacher said to use github for our project but he just is going to look at a word document so what is the point of github

deep goblet
#

making sure it can interact with unity and it's functions and other stuff

summer stump
#

If you say extensions, I assume vs code

rich adder
summer stump
deep goblet
polar acorn
#

You can view each draft all at once if it's in git

deep goblet
#

portfolio after you graduate

polar acorn
#

Also it prevents someone from just pasting a ChatGPT essay into the submission box and calling it a day

deep goblet
#

(saying that because i wish i had one, i made some epic stuff eeeexcept it all saved to my old school email)

dire tartan
#

is this the right place to ask for help with coding problems?

slender nymph
#

yes

frigid sequoia
#

How can I know what part of the object is "the front" for stuff like lookAt()?

slender nymph
#

forward is along the Z axis (blue arrow)

#

!code

eternal falconBOT
dire tartan
#

oh sorry

slender nymph
#

it's backticks, not apostrophes. but also use a bin site for large blocks of code like that

#

anyway, i cannot see the line numbers so i don't know which is line 32, but at a guess i'd say it's probably FixedJoint fj = grabbedObj.AddComponent<FixedJoint>(); and grabbedObj is null because you aren't null checking it there

dire tartan
#

yes that was line 32

frigid sequoia
dire tartan
#

to send a hatebin i just send u the link?

slender nymph
slender nymph
dire tartan
#

okay thank you

pearl lodge
#

how to change color of sprite render?

pearl lodge
#

I tried that

slender nymph
slender nymph
dire tartan
#

yeah got it thank you

polar acorn
pearl lodge
polar acorn
# pearl lodge

Renderer doesn't have anything named color. SpriteRenderer does.

slender nymph
#

and Renderer does not contain that property. that is on the SpriteRenderer class

frigid sequoia
slender nymph
open apex
#

Event takes place, no errors, no "The event has happened" in the console

slender nymph
polar acorn
ivory bobcat
acoustic sun
#

So I was able to fix some of the issues on my script, but now I came across another problem where it shows this

polar acorn
acoustic sun
open apex
polar acorn
acoustic sun
#

I do

slender nymph
# acoustic sun

you probably have your own class called CharacterController so it's trying to use that instead of unity's CharacterController

north kiln
#

Do you have an IDE that is configured...

polar acorn
acoustic sun
#

I did that already, and I am still getting the same error

acoustic sun
polar acorn
eternal falconBOT
acoustic sun
# eternal falcon

Is this something I have to do on my script or something that is shown on discord?

ivory bobcat
# acoustic sun

Intellisense should not have suggested the field/property and marked it as an error immediately in Visual Studios.

acoustic sun
#

I used gdl

#

What do I do to share it?

polar acorn
#

give the link

acoustic sun
#

Thank you so much. Im sorry for taking a while. I am new to code and I am not able to figure things out "right-a-way"

north kiln
#

Is your IDE configured?

#

Because I can see something that would be underlined

#

and other things that should be correctly indented

polar acorn
#

Why do you have two variables who only exist to set each other

#

this would be a stack overflow as soon as you tried

slender nymph
#

actually that second one sets and gets the field from line 11. but that first property is very weird

acoustic sun
ivory bobcat
polar acorn
#

Oh, right

north kiln
polar acorn
#

I got PlayerController blinded by how many were in one place

acoustic sun
acoustic sun
ivory bobcat
#

Did you setup your workloads? (a common missed item from the list of things to do from the configuration manual)

acoustic sun
ivory bobcat
north kiln
#
  1. Open the Visual Studio Installer.
  2. Select Modify
  3. Select Workloads
  4. Make sure the Game development with Unity workload is enabled
ivory bobcat
#

Running the installer again will allow you to modify Visual Studio

#

At the very least, the Unity workload must be checked.

acoustic sun
# ivory bobcat

It is not giving me that option to do that. I have already downloaded Visual Studios

north kiln
#

Screenshot what you are doing

ivory bobcat
#

What's not giving you the option?

acoustic sun
#

The workload tab

north kiln
ivory bobcat
#

Show us your workload tab or whatever it is that you're looking at.

acoustic sun
#

This is what it is showing me

north kiln
#
  1. Select Modify
teal viper
#

I think we'll have to explicitly go through each step with them.😅

acoustic sun
#

Yeah I apologise if I am slow lol

teal viper
#

Did you get the ide to underline the errors?

#

Also !code

eternal falconBOT
rich adder
ivory bobcat
hot talon
#

jjooo I need help my Visual Studio is weird af notlikethis

#

I use 2022 and it doesnt really work together with Unity

ivory bobcat
#

Maybe tell people what is weird with it.

hot talon
#

Hard to explain but I want to write code for my Vr hand. I creat a c# file and write code but it just doesnt appear in Unity

ivory bobcat
#

What do you mean by "it doesn't appear in Unity"?

#

I'm assuming "it" refers to your script not appearing in the Unity Editor

hot talon
#

uuuh sorry I am new but when you creat a Script there should be variables that appear in Unity when you write it down in the code. wait let me make some screenshots

ivory bobcat
#

Maybe share your !code

eternal falconBOT
slender nymph
hot talon
#

yeah thats fine

#

There are no channels that you can join to Share your screen right?

ivory bobcat
slender nymph
eternal falconBOT
hot talon
#

aahhhh thanks

slender nymph
#

then when you've done that fix your spelling

hot talon
#

bro thank you very much for helping me but it is midnight on a school day for me plus I am not from a native english speaking country... or whatever you call it

rich adder
#

lol you're the one who posted asking for help

#

should've asked earlier

slender nymph
#

the issue is literally caused by a spelling mistake too

ivory bobcat
#

A configured IDE is required to get code help on this server. Maybe wait till you've got more time to debug this if you're busy.

ivory bobcat
teal viper
hot talon
#

💀 yeah got it now. I used JetBrains for java before this, so I am not used to configurate stuff... found the two spelling mistakes too... thank you everyone you saved me

ivory bobcat
#

When an IDE is configured, the Intellisense will provide code suggestions that will prevent most (if not all) typos and minor syntax errors.

#

You'd not be able to continue to the next line without the whole script throwing red squiggly lines everywhere or having completely messed up indentations - as the statements are likely invalid.
You'll be able to focus more on designing and actual logical errors rather than syntax errors.
You'll also be more aware of the available members of a type without having to lookup the docs - you should read them anyways, at least for the specific tool you're using (nobody really remembers the docs in detail... they're just aware of the constraints and patterns for the tools they find themselves often working with).
A properly configured IDE makes a huge difference in productivity.

open apex
#

Hello, it's me again. I have finished flappy bird

#

I am having an issue with a code I am writing.

#

There 4 scenes

#

from 0 to 3

ivory bobcat
open apex
#

I wrote so it would be chosen from scene 1-3 but it would never choose scene 3

#

so I wrote from 1-4

#

and now it works

#

isn't that weird?

#

or am I just unlucky

ivory bobcat
open apex
#

Thanks for the help

ivory bobcat
rotund hull
#

!code

eternal falconBOT
rotund hull
thorn holly
#

Uh we can’t see your code

#

That’s a link to the paste site

#

But there’s no code in that link

#

@rotund hull

summer stump
vale karma
#

what kind of capitalization should I use for c#? I saw a video where he said to make public variables LikeThis and private variables _likeThis. is that the right way to do it? Ive just been doing it likeThis

vale karma
rocky canyon
rich adder
rocky canyon
#

sure it does

vale karma
#

okay, and do private variables get the '_' in front?

rich adder
#

its choice at the end of the day

rocky canyon
rich adder
#

I used to but dont the point anymore

rocky canyon
#

i also just do pascalCase

rich adder
#

code with a lot of _ looks ugly to me now 🥹

teal viper
rocky canyon
#

private static IWorkerQueue s_workerQueue;

vale karma
#

its hard to understand what variable needs to be accessed outside the class, im still kinda new to it, so when i think it needs to im more generous with private until i hit error codes

rich adder
#

string hello = "hello_world_I_like_to_code" <- seen someone do this recently

north kiln
vale karma
#

i have just learned kind of what public type name {get; private set;} means, i tried using it a little and i got error codes

vale karma
#

uhmm i took it all out ill recreate the issue one sec

#

Cannot modify the return value of 'expression' because it is not a variable

#

compiler error CS1612

north kiln
vale karma
#

oh wait i havent made the class yet

rich adder
vale karma
#

ok im confused now, heres my code

teal viper
#

When you access a vector via property, it creates a copy of the original variable, so modifying it doesn't make sense, and this the error.

#

If you want to change a value type via a property, you need to cache the whole thing in a local variable, modify it however you like and reassign the whole thing back.

#

You can also skip the first step if you don't need the previous values.

#

In this case you'd need to create a new instance.

vale karma
#

i feel like thats a bit too advanced for me atm

teal viper
#

Not really. Knowing the difference between value and reference types is one of the basic things you need to know.

#

Everything else is a consequence of that

vale karma
#

i meant learning how to do that and a state machine at the same time, i gottapick a lane and figure one out, if i am debuging both at the same time that would be horrible

edgy forge
#

my build for android is only getting this far. no errors during play in the editor, and it was building a few days ago. not much has changed that I can think of reverting. is there a way to debug the build process?
it just sits at this point, even overnight

summer stump
teal viper
vale karma
#

dang and i was excited to get this done today

summer stump
#

It's like saying "I don't know what a class is, I want to learn how to make an object pool first"

vale karma
#

yea makes sense

rich adder
edgy forge
#

ok, thanks

rose galleon
#

Hey, so, I been getting this message: Assets\Scripts\GameController.cs(39,9): error CS0120: An object reference is required for the non-static field, method, or property 'SavePoint.SavePosition

The line of the code is: SavePoint.SavePosition = Player.transform.position;
I am trying to refer to the Vector3 stored in the SavePoint script, called SavePosition, to teleport the player there. any idea of the problem?

swift crag
#

which SavePoint instance, though?

#

SavePoint is a class. It's a kind of object.

#

SavePoint.SavePosition is trying to get SavePosition from the class itself

#

You haven't provided a specific save point to set SavePosition on here.

rose galleon
#

i think I get it

swift crag
#

that's why it says you need an "object reference"

#

Transform.position = Vector3.zero is an error because you need to set the position of a specific Transform, not the Transform class itself

#

transform.position = Vector3.zero is fine because transform is a property on MonoBehaviour that gives you an instance of the Transform class

rose galleon
#

so I need to instantiate the SavePoint script?

swift crag
#

If it's just a regular class (not a MonoBehaviour or ScriptableObject or something), you'll want to create an instance, store the data in it, and then hang on to the object

#

I don't know what SavePoint is so I can't say for sure.

rose galleon
#

got it

rose galleon
swift crag
#

SavePoint is a class that derives from MonoBehaviour

#

so SavePoint is a component that exists in your scene?

rose galleon
#

yes

#

a script, assigned to an object

swift crag
#

how is this meant to work?

#

do you want to remember the player's position after you reload the scene?

#

or is this just remembering where the player was so that you can respawn within the same scene

rose galleon
#

there is a scene. Within the scene, the Save GameObject exists, having the SavePoint script. When the player dies, I want them to respwan at the Save gameObject's position

swift crag
#

Okay, that makes sense.

#

I think the Save Point should detect when the player touches it using a trigger.

rose galleon
#

i find this better in a long term than having set Vector positions, so the Save GameObject can be in different positions in different scenes

swift crag
#

When that happens, it should do two things:

  • Remember the player's exact position
  • Tell the GameController that it should be the active save point
rose galleon
swift crag
#

oh, did your Save Point class tell the Game Controller about the player hitting it?

rose galleon
#

tho the player position doesnt matter to me, the only position that matters is the Save position

rose galleon
swift crag
#

that doesn't answer my question

#

does SavePoint call a method on GameController?

rose galleon
#
void OnTriggerEnter2D(Collider2D other)
    {
        if(other.gameObject.CompareTag("Player"))
        {
            GameController.instance.Save = currentSave;
        }
    }
swift crag
#

where is this code from?

rose galleon
#

the SavePoint script

swift crag
#

then what is currentSave?

#

is that not a SavePoint?

rose galleon
swift crag
#

just add another field to the game controller to store the position of the save point

#

GameController.instance.SavePosition = transform.position;

rose galleon
#

GameController not being destroyed on load wouldnt mess this up tho?

swift crag
#

why would it?

rose galleon
#

true

swift crag
#

it already remembers the Save string

#

Storing the SavePoint itself would be inappropriate

#

since the SavePoint would get destroyed on scene unload

rose galleon
swift crag
#

Right.

#

Just like Save is a string

#

I would rename that to saveScene

#

it's the scene you saved in

rose galleon
swift crag
#

and savePosition is where you were

rose galleon
#

this is so much easier

swift crag
#

it's easy to get stuck on the wrong idea :p

#

You could go a step further and make a serializable SaveData class

#

and then use JsonUtility to save that into JSON and also load it back into an object

#

then you could save the game between play sessions

rose galleon
swift crag
#

If your save data is simple, the built-in JsonUtility methods can easily handle serialization for you

#

for more complex things, Json.NET is popular (you might've seen the "Newtonsoft" name before)

#

I use it for saving.

rose galleon
#

huh. everything is working as it should, except the respawn point. the player is still not respawning on the Save .-.

swift crag
#

did you update your code to actually use the savePosition value?

#

not just to write it

rose galleon
#

SavePosition = Player.transform.position;

#

SavePosition being a Vector3 in GameController

swift crag
#

Okay, but where do you use that variable?

rose galleon
#

https://hastebin.com/share/ebohutusoz.cpp
I think maybe this is somehow overriding the "SavePosition = Player.transform.position;"

swift crag
#

Just remembering the value doesn’t do anything by itself

rose galleon
swift crag
#

That’s storing the player’s position into the savePosition variable

#

That’s good, but if you never actually read the value from savePosition, it’s kind of pointless…

rose galleon
#

.-. oh

#

isnt there a thing like "findObjectWithTag" or something like that?

winter prawn
#

Compare tag?

summer stump
rose galleon
#

because since the GameController doesnt originally exists in the same scene as the Save GameObject, I need to find a way to bring the GameObject into its script through the script, not assigning it in the inspector, so I can store its position

summer stump
summer stump
rich adder
summer stump
# rose galleon uhh how exactly?

GameObject newObject = Instantiate(prefab);

You can also store whatever the prefab type is, like:

public Player prefab;

Player newPlayer = Instantiate(prefab);

You rarely want a GameObject reference

summer stump
rich adder
rose galleon
#

Thanks yall

storm imp
#

@north kiln would I do that whole line the same except for time.deltatime?

north kiln
#

Yes, and fix the capitalisation mistake in the axis

north kiln
spare latch
#

Just curious, I know when learning ChatGPT is normally not a good idea. Im just wondering if first I figure out a way to add something for example (Movement for 2 paddles in pong). Get it all working and whatnot, then asking ChatGPT to imrpove my code, then using that code.

I did all the "hard" work by adding the feature myself, but I have ChatGPT optimize it and help me to understand why its code is better than my code and what not.

I guess my question is just will it still be a good way to learn, or should I just stick to solely writing the code myself.

storm imp
rich adder
#

and its still wrong UnityChanLOL

teal viper
north kiln
#

and I think getting it involved in any stage is a bad idea

spare latch
teal viper
spare latch
storm imp
north kiln
#

Just remove the deltaTime multiplication

teal viper
storm imp
teal viper
#

And by understanding the code, I don't mean just functional understanding, but also intentional. You need to understand why it was done this way and not another and wether it would work in a different way and how.

spare latch
#

Appreciate the advice

vast vessel
#

I have this IEnum that will move a transform, to another position, based on animation curves. one for the speed, and one for the height offset.
this is all running in a while loop, that will run as long as timer is < leg.travelTime.is there a way for me to remap timer from 0, leg.travelTime to 0,1 to use it for evaluating my animation curves? since my animation curves run from 0 to 1, and not from 0 to leg.travelTime.

faint sluice
#

In this case Timer/leg.travelTime usually would send value between 0-1 no?

north kiln
#

You should not use WaitForEndOfFrame, it's not doing what you intend it to

#

you should just yield return null to wait a frame

#

float normalizedTime = timer / leg.travelTime;

vast vessel
storm imp
#

how do I fix it?

vast vessel
#

your unity version is diffrent then the one you last saved your project on

#

you can continue but it might break some things

#

or download the original version of the editor.

storm imp
#

I don't get it that's how I opened it the last time

vast vessel
#

make a backup of your project, then open it again and press continue

vast vessel
storm imp
vast vessel
#

dude. go into your project's folder, make a copy somewhere else. re open the project, then if this same message pops up press continue. its not that hard

storm imp
vast vessel
storm imp
#

now what?

vast vessel
storm imp
#

I already did this

vast vessel
#

read that thing. it says go to prefrances>external tools and then set VS as your external editor

storm imp
#

I keep getting this

#

@vast vessel

vast vessel
#

press continue

spare latch
#

Does it not say there’s no space left on your drive?

rich adder
storm imp
#

I'll fix that tomorrow

#

can I save it to a different drive?

summer stump
# storm imp backup?

You should use version control (git or unity version control (i recommend git)), not make a copy of the folder. Just for the future

summer stump
storm imp
summer stump
#

If you ever see a word you don't recognize, you should immediately google it
In this case, something like "how to use git with unity"

storm imp
#

I'll fix it tomorrow

fierce geode
#

How much does GetComponent effect performance? Been trying to not use it as much as possible. But is it like, using it like once when something specific happens is fine, it's more so when you're doing something every frame it becomes a problem?

#

Was wondering because in my ontriggerenter script for my character, everytime it enters a trigger; it'll be checking if that trigger object has a checkpoint script

#

Wondering if I should switch to just creating a tag for checkpoint objects so I can just check if there's a checkpoint tag, or if it doesn't matter too much.

twin bison
#

Hi do I have to unsubscribe from an event where i delete the object that invokes the event?

private void OnEnemyDied(EnemyController enemy)
    {
        enemy.Died -= OnEnemyDied;
        _spawnedEnemies.Remove(enemy);
        Destroy(enemy.gameObject);
    }
fierce shuttle
# fierce geode Was wondering because in my ontriggerenter script for my character, everytime it...

You could use TryGetComponent<T>(out someVar) or TryGetComponent(out T someVar): https://docs.unity3d.com/ScriptReference/Component.TryGetComponent.html - if the component does not exist, no extra memory will be allocated, if it does, then itll be stored in "someVar" - in general "GetComponent" isnt exactly bad, its just often times you can probably cache your reference, it does generate (a small amount of) garbage when called, and scans all components of a object, avoiding it in large loops and functions like Update can give micro optimization, but probably wont be the leading cause of major performance issues in your project (though for that, the Profiler is a good tool to confirm and find performance issues)

native seal
#

anyone know how I can fix the color?

    {
        StringBuilder builder = new StringBuilder();

<color=#").Append(Rarity.Color.ToHexString()).Append(">").Append(Rarity.Type.ToString()).Append(" ").Append(EquipmentType.ToString()).Append("</color>").AppendLine();


        return builder.ToString();
    }
}```
#

right now it just deletes the text

gaunt ice
#
<color=#").Append(Rarity.Color.ToHexString()).Append(">").Append(Rarity.Type.ToString()).Append(" ").Append(EquipmentType.ToString()).Append("</color>").AppendLine();
```what is this? and did you log the builder.tostring
native seal
#

yes

gaunt ice
native seal
#

the line doesn't show

fierce shuttle
# twin bison Hi do I have to unsubscribe from an event where i delete the object that invokes...

Unsubscribing can always be a bit confusing, as a good rule of thumb I always try to unsubscribe anyway, though maybe this post can clarify: https://forum.unity.com/threads/unsubscribing-listener-in-c-object-instance-within-monobehavior.1252914/#post-7963866 - as I understand it, if the thing being destroyed has subscribed to something that wont be destroyed, then it should unsubscribe itself before getting destroyed

gaunt ice
native seal
#

nvm got it

#

string color = ColorUtility.ToHtmlStringRGB(Rarity.Color); have to use this

gaunt ice
#

you should use string interpolation (or string.format) instead of append.append.append....

native seal
#

apparently string builder is way better with memory?

gaunt ice
native seal
#

ah so use string.format but not concatonation

gaunt ice
#
.append().append().append().... 7 appends vs
$"abcd {var0} efgh {var1} ijkl {var2}\n"
native seal
#

in string.format do i just use + in place of append?

gaunt ice
#

string.format is

Format("abcd {0} abcd {1} abcd {2} ...",var0,var1,var2.....);
#

no idea what you mean by +

native seal
#

nvm

#

got it

gaunt ice
#

btw the number inside {} tell which argument it needs, so you can

Format("{0} abcd {0}",var0);
native seal
#

Is there a reason it doesn't work with the $ infront?

#

because my ide doesnt syntax highlight without it

#

if I put it it breaks

modest dust
gaunt ice
#

with $ you dont need to maintain the order of arguments inside string.format, just

return $"abcd {var1} abcd";
native seal
#

ah okay

gaunt ice
#

short hand of format

native seal
#

when I try to tab it down a line to make it more readable it adds a +

#

pretty annoying

scarlet sinew
#

Hi, I keep getting this error . I have tried the most basics of tech support advice of turning it off and on again. Please can someone advise me how to clear this error?

gaunt ice
#

you dont need format any more, string interpolation already returned you a string

native seal
#

i know, but to make it more readable for me

vale karma
#

can you still change a variable from another script if its private?

modest dust
#

Or internal I guess

gaunt ice
#

reflection /pointer (if unmanaged struct)

vale karma
#

okay, i think im understanding getters and setters now

#

i thought private types werent able to be used if it was outside the class. I realize you can read the value but you cant change it if its setup with a get and private set, but its not readable or writable if its just private, am i right on this?

modest dust
native seal
#

public x {get; private set}
is just shorthand for getters and setters, x is actually private

vale karma
#

correct i keep forgetting its actually public

#

isnt it x is private when setting and public getting?

native seal
#

if you use properties the variable is private even though it technically says public

#

its just shorthand

#

properties being {get; set}

opaque mortar
#

!code

eternal falconBOT
opaque mortar
#

hi i have this erroa Assets\Main\Scripts\InputManger.cs(24,49): error CS1061: 'PlayerMotor' does not contain a definition for 'Crouch' and no accessible extension method 'Crouch' accepting a first argument of type 'PlayerMotor' could be found (are you missing a using directive or an assembly reference?)
this my code https://gdl.space/raw/ugeriyedux

native seal
#

idk check ur PlayerMotor class

opaque mortar
vale karma
languid spire
opaque mortar
#

i know notlikethis

languid spire
#

crouch is not the same as Crouch

vale karma
#

oop i fixed it i think

#

makes so much sense now that i did it lol

opaque mortar
languid spire
#

change crouch to Crouch ?

opaque mortar
#

ok

languid spire
#

if you really needed to be told that you need to follow some basic C# lessons

opaque mortar
gaunt ice
#

py is case sentitive

nimble scaffold
#

!ide

eternal falconBOT
nimble scaffold
#

That's all'

ripe kayak
#

i can't find the playgame or quitgame function

languid spire
#

screenshot inspector

ripe kayak
#

whar

languid spire
#

ok, screenshot console

ripe kayak
#

this is from YT is what im trying to do

#

i can't find these 2 (QuitGame + PlayGame)

languid spire
#

did you save your script?

ripe kayak
#

yep

#

i did save manualy

#

this what i found

languid spire
#

So fix your errors

ripe kayak
#

oh i see the problem lol

#

people call me blind for a reason

#

i wrote screenmanager instead of scenemanager

languid spire
#

and just did it again, lol

ripe kayak
#

done

#

thx alot

languid spire
#

you need to configure !ide, those errors should have shown up there

eternal falconBOT
ripe kayak
#

let me check the bot rq

languid spire
#

Here, this line should be red underlined

ripe kayak
#

what should i do about it? (im a beginer tw lol)

languid spire
#

which IDE are you using?

ripe kayak
#

i have no idea what IDE even means

languid spire
#

the program you use to type code into

ripe kayak
#

im using it

languid spire
#

that looks like VS Code not VS

ripe kayak
#

they are not same?

#

wowie

languid spire
#

no, not at all

ripe kayak
#

uhhh is it an issue?

languid spire
#

yes, without a configured IDE you cannot get help here

ripe kayak
#

lmao i think i should install it then

languid spire
#

yes, Visual Studio (Community) is best to use

ripe kayak
#

soooo this one right?

languid spire
#

yes

#

or you can install via the unity Hub

ripe kayak
#

i didn't find it in unity hub for some reason but ok

#

this one?

languid spire
#

yes

#

no, Unity one

ripe kayak
#

oh

languid spire
#

yes

tepid summit
#

this is a genuine screenshot

languid spire
#

Time to learn about Arrays @tepid summit

tepid summit
#

this was like 2 or 3 months ago

rose galleon
#

Just download the c# and unity extensions?

earnest atlas
#

Yes

#

Tho visual studio and visual studio code are different things

languid spire
eternal falconBOT
rose galleon
#

You think throwing copilot in there would mess up my learning process like ChatGPT?

languid spire
#

yes

earnest atlas
#

mess up what exactly?

rose galleon
#

Yk, like chatgpt gets you stuck in a tutorial hell sort of way? It just gives you a code and complicated explanation

earnest atlas
#

well if you use to generate all code for you withtout bothering to undestand anything then yes

languid spire
#

kinda, these are really not learning tools and should only be used by someone who already knows what they are doing

earnest atlas
#

I would say they are learning tools depending on what language u want to learn and if you have any base or not

#

some not so known languages it hallucinates almost entire code

rose galleon
#

Tho copilot still needs you to know something, so I guess it isn't that bad?

earnest atlas
#

I mean everything requires you to know what u are doing

#

it can give u legit looking code that is not what you need at all

languid spire
#

One of the most difficult jobs in software development is debugging code that you didn't write, and code generated by CoPilot or GPT makes this doubly difficult

earnest atlas
#

lets add when it gives you code that gives no eror messages when it fails 🙂

#

Im looking at you android

fierce geode
#

For coding in Unity, are you supposed to use Visual Studio or Visual Code?

#

I use Studio, I honestly dont know the difference between Code and Studio

gaunt ice
#

it is called visual studio code or vsc not visual code

languid spire
quaint flicker
#

random question: why does the unity starter assets tpp example ThirdPerson controller example includes a spherecast for a groundcheck if the CharacterController already provides an isGrounded property?

eternal needle
teal viper
#

Even unity admits that CC sucks.😬

eternal needle
#

It is pretty awkward when you are limited to its options, and requiring that you do 1 move per frame or it might be buggy.

jaunty coyote
#

how do you acces blend tree values?

rare basin
#

as you normally access animator parameters

jaunty coyote
#

whoopsie, i had a sort of local float value going on in the blend tree, al fixed

vast vessel
#

can anyone tell me why im getting this error? the Agent of AI_Health is assigned in Ai_Agent script in awake. and i did check before Die was called, it was indeed assigned.

error :

NullReferenceException: Object reference not set to an instance of an object
DELTAV.AISys.AI_Health.Die () (at Assets/Scripts/AI_AgentSys/AI_Health.cs:41)
DELTAV.HaDSys.HaDSys_Damagable_Base.TakeDamage (DELTAV.HaDSys.HaDSys_DamageInfo damageInfo) (at Assets/Scripts/Health And Damage System/HaDSys_Damagable_Base.cs:20)
DELTAV.AISys.AI_Health.TakeDamage (DELTAV.HaDSys.HaDSys_DamageInfo damageInfo) (at Assets/Scripts/AI_AgentSys/AI_Health.cs:30)

AI_Health script : https://hastebin.skyra.pw/oriyorakap.csharp

#

the debug.log on line 37 outputs Agent is . and dosnt say the game object name

gaunt ice
#

where it is assigned?

languid spire
#

if Agent is not null then Agent.speaker must be null

pastel pollen
#

Is it overkill to mark things like DeltaTime as [ReadOnly] when used in jobs, or is it a good practise?

gaunt ice
#

what deltaTime?

vast vessel
vast vessel
gaunt ice
#

try log with the gameobject to see which one gives you NRE

vast vessel
languid spire
#

name or Type?

#

show console

vast vessel
# languid spire show console
Agent is 
UnityEngine.Debug:Log (object)
DELTAV.AISys.AI_Health:Die () (at Assets/Scripts/AI_AgentSys/AI_Health.cs:37)
DELTAV.HaDSys.HaDSys_Damagable_Base:TakeDamage (DELTAV.HaDSys.HaDSys_DamageInfo) (at Assets/Scripts/Health And Damage System/HaDSys_Damagable_Base.cs:20)
languid spire
#

so Agent is null

gaunt ice
#

agent is null so nothing got displayed
btw

Log("XXXX",gameobject);
languid spire
#

debugging a null object does not throw an exception

vast vessel
#

but i can see it assigned in the inspector!

languid spire
#

how? Agent is not serialized

vast vessel
#

also every other thing that AI_Agent assigns in Awake works fine

vast vessel
gaunt ice
#

duplicate component

vast vessel
#

elaborate please

languid spire
#

wait.
Agent is a property. How can it ever know what to get?

gaunt ice
#

you probably have two components of this script
search the hierarchy or debug.log

vast vessel
#

no i only have one

vast vessel
languid spire
#

you need a GetComponent before you access the property

#

you are not setting it to anything

languid spire
vast vessel
#

even when i assign Health's agent through its own inspector i get the error!

#

what is this bull shit

placid wadi
#

a question, how to make the game look sharp? I mean my game feels blurry for some reason 🤔

vast vessel
#

on the top it has an option for it

#

set it to free aspect or your own screen resolution

#

might be your bloom

placid wadi
#

is there a way to have a lot of bloom but without the blurriness or is it a lost cause in that case?

#

i really like the bloom haha xD

placid wadi
#

ah shi sent in wrong again haha xD

vast vessel
#

yea so uhh i cant send pictures on discord cuz im in iran,

#

but i assure you it is correct

languid spire
#

ok add logs to the Awake

vast vessel
vast vessel
static vigil
#

Hey I'm working on a XR project and I'm trying to make teleporters you can step on and go to a certain other location. The problem is I don't think what ever collision box I'm using is colliding with the teleporter. Could someone help me? (my code is attached btw)

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

public class Teleport : MonoBehaviour
{
    public Transform teleportTarget;
    public GameObject thePlayer;

    void OnTriggerEnter(Collider other)
    {
        thePlayer.transform.position = teleportTarget.transform.position;
    }
}
languid spire
tepid summit
placid wadi
tepid summit
#

all g

tepid summit
hexed terrace
tepid summit
#

and use something like a tag comparison to filter it

tepid summit
#

wdym

static vigil
#

I have a cylinder with capsule collider running that script and my XR camera isn't colliding ig

vast vessel
# languid spire ok add logs to the Awake

i logged both the health and health's agent after assigning it at the end of awake.
both were logged correctly:

UnityEngine.Debug:Log (object)```
```Strider (DELTAV.AISys.Strider.AI_Strider)
UnityEngine.Debug:Log (object)```
(btw `AI_Strider` in the log is of type `AI_Agent`)
static vigil
tepid summit
#

does the teleport have a coll

languid spire
# vast vessel alr

just a thought.
You have Awake as Virtual, this suggests a inherited class somwhere that may not be executing this Awake

static vigil
tepid summit
#

check

static vigil
vast vessel
hexed terrace
static vigil
vast vessel
# languid spire post that code

also other things in AI_Agents awake get assigned sooo....

here is the awake of ai agent right now:

protected virtual void Awake()
        {
            aiTarget.faction = faction;
            speaker.Agent = this;
            targetingSystem.Agent = this;
            targetingSystem.faction = faction;
            targetingSystem.los = ai_Los;
            

            health.Agent = this;
            Debug.Log(health);
            Debug.Log(health.Agent);
        }```

this is AI_Strider :
```cs
        protected override void Awake()
        {
            base.Awake();
            -----other shit-----
        }```
static vigil
#

I will test it now

languid spire
tepid summit
tepid summit
static vigil
tepid summit
tepid summit
static vigil
vast vessel
static vigil
tepid summit
static vigil
#

ok should be centered now

tepid summit
static vigil
#

but since it said zero i just thought it didnt move 😂

tepid summit
#

ah

#

i see

static vigil
#

ok it looks good now

#

ill set the other thing to whatever rq

tepid summit
#

ok

#

so it works?

static vigil
#

idk

#

im gonna test it now

#

gimme a sec

vast vessel
#

@languid spire isnt this unusueal? i also have another script called AI_Soldier of type AI_Agent and that works fine?

#

that one dosnt have any problems with its AIHealth

tepid summit
#

is that mixed reality

languid spire
vast vessel
static vigil
#

so it didnt work

tepid summit
#

so its just another way of saying it

static vigil
#

its just what unity calls it

tepid summit
tepid summit
static vigil
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Teleport : MonoBehaviour
{
    public Transform teleportTarget;

    void OnTriggerEnter(Collider collider)
    {
        collider.transform.position = teleportTarget.transform.position;
    }
}
vast vessel
tepid summit
#

i do have an idea

#

do you mind rewriting the code

static vigil
static vigil
vast vessel
#

OnTrigger enter needs a rigidbody

static vigil
#

breh

vast vessel
#

put a Kinematic rigidbody

tepid summit
vast vessel
#

on your player

static vigil
#

i have a colider though

hexed terrace
tepid summit
vast vessel
hexed terrace
#

it's a term for VR and AR

tepid summit
#

doesnt matter if kinematic or not

static vigil
tepid summit
#

make sure to constrain rotation

static vigil
#

im new to all this stuff lol

hexed terrace
#

the link I gave you went through all this ..

vast vessel
tepid summit
#

just ssaying

static vigil
#

ok i gave it a rigidbody

tepid summit
#

did you constrain rotation

static vigil
#

now i did

#

so it just

#

works now?

#

do i still need the capsule collider?

vast vessel
#

didnt you originally need it for something else like.... not phasing through walls?

languid spire
#

@vast vessel Can you show the sequence of the debug.logs you are getting

static vigil
#

not yet

static vigil
#

ok so i loaded in anddd then everything was just gone..

#

did i fall through the floor?

vast vessel
languid spire
static vigil
#

like aim the controller click a button

vast vessel
static vigil
languid spire
vast vessel
#

how do i enable the debugger?

languid spire
#

Attach To Unity button

#

in VS

static vigil
#

ayyyy lets goo it works

tepid summit
#

ayyyyyyyyyyyyyyyyyyy

static vigil
#

theres just.. one more issue

#

._.

#

my aim click teleport thingy, its getting blocked by something now i guess and it only blocks it like 30deg in front of the player and the rest of the directions work fine

vast vessel
languid spire
#

you might have mentioned that earlier!!!!!!!!!!

vast vessel
rare basin
#

they are

#

because of that error other things might broke

languid spire
#

does not matter, not disclosing ALL information or drip feeding it does not make it easy to help you

vast vessel
#

oh wait. i think that error is beacuse i was already in playmode when i pressed attach to unity

#

beacuse it is not ususal

rare basin
#

what is the error

#

maybe you can finally tell us?

vast vessel
# rare basin what is the error

well.... after i pressed attach to unity i have 23, 250 stacked errors, going up on every frame. mostly null exceptions.
yea that happens when i compile code when my game is running

#

gimme a sec

tepid summit
rare basin
#

okay and what is the error

#

jezus

vast vessel
tepid summit
#

thats not an error

rare basin
#

you'll keep us guessing

#

or what

vast vessel
#

i said it was beacuse i attached to unity when i play mode. now they are gone

static vigil
tepid summit
#

mostly nre's i bet

tepid summit
#

air sorry

#

layer

#

not tag

#

put it on ignore raycasy layer

static vigil
#

like exclude

tepid summit
#

oh wait

vast vessel
#

well what do i do now? how do i see the execution order @languid spire ?

tepid summit
#

you can t layer specific components

vast vessel
#

i am in play mode

static vigil
tepid summit
#

player settinga

static vigil
tepid summit
languid spire
#

you set breakpoints in your code and see which ones fire and in what sequence

tepid summit
#

yeah try that

static vigil
#

but should it be on exclude or include

tepid summit
#

try one then both

static vigil
#

ok

tepid summit
#

see what works

#

wait

#

i think thats just the layers the rb interaacts with

#

so it only will collide with things that ignore raycast

languid spire
tepid summit
static vigil
#

uhhh sure

vast vessel
languid spire
#

no

#

it means the Awake in strider is not being executed

vast vessel
tepid summit
#

is it written exactly the same?

vast vessel
#

at the start of Awake

#

look at the code

languid spire
tepid summit
vast vessel
vast vessel
tepid summit
tepid summit
vast vessel
languid spire
#

So if you put a breakpoint in AI_Agent.Awake you can look at the stack trace and see how it got there

vast vessel
languid spire
#

damn, this is so difficult without screenshots, can you try to fix that?

vast vessel
#

I will try

#

This is so weird tho

#

Like why is it so hard to assign a value?

languid spire
#

it is indeed and I bet there is a real simple explanation for it

tepid summit
#

is it being overridden anywhere?

languid spire
#

thats the point of using the debugger, to find out

tepid summit
#

fair enough

languid spire
#

his code is pretty complex

tepid summit
#

pretty?

languid spire
#

lots of inheritance

tepid summit
#

yes

tepid summit
vast vessel
tepid summit
#

which would be wierd to get an nre from but still

tepid summit
languid spire
#

with the project and the VS debugger I could solve this in 5 minutes, just based on the code is somewhat trickier

tepid summit
#

i believr i havr a lead

vast vessel
#

Wait.... u got anydesk?

languid spire
#

can you send your project via Google drive or something?

tepid summit
vast vessel
tepid summit
#

are we gonna IT team this

languid spire
vast vessel
#

Guys i gtg. I will come back to makig you suffer in like 15-30 mins

languid spire
#

I'm out for the rest of the day shortly, I'll tag you when I get back

rare basin
vast vessel
rare basin
#

ok and how is that related

#

to the Library folder

#

you can delete the Library folder and zip&send the project

#

then whoever opens it, it will build the llibrary for him

scarlet skiff
#

does anyone have any advice regarding how i can make a gameobject "split" into two? (destroyed and then instantiates 2 more in OnDestroy with a smaller scale), not only can i not do it correctly i also get the error "Some objects were not cleaned up when closing the scene."

should i instead spawn these gameobject in the OnCollisionEnter2D method? and then i call Destroy

#

or maybe if anyone has a good tutorial for this situation

vast vessel
rare basin
#

Library is not your assets folder

#

you can safely delete the Library folder

timid saffron
#

im trying to make the rotation the opposite

rare basin
#

read the error

#

rotation is a Quaternion

timid saffron
#

it says * cant be aplied

rare basin
#

it's not a Vector3

timid saffron
#

👍

rare basin
keen dew
#

no that won't even compile

timid saffron
#

i found out that theres a local var called inverserotation

#

its handy 👍

rare basin
#

sorry

timid saffron
#

it doesnt. i tried

rare basin
#

i did mistake, edited now

#

i meant eulerAngles*

keen dew
#

What if eulerAngles is (0, 0, 0)?

rare basin
#

then it will be 0,0,0

keen dew
#

which is the same, not opposite direction

rare basin
#

but what would be the opposie direciton of 0,0,0

#

when the player has no rotation

#

Inverse() would also set it to 0,0,0

earnest atlas
#

sprite rotation is not object rotation

rare basin
#

if euler angle is 0,0,0 then both methods will be the same result

rare basin
earnest atlas
#

also make object with sprite child of object you are moving

#

otherwise moving it will be confusing

rare basin
#

if eulerAngles is (0,0,0), then
Quaternion.Inverse(Player.transform.rotation) will return the same value as Quaternion.Euler(-Player.transform.rotation.eulerAngles); im pretty sure

keen dew
#

seems like a silly feature to have

rare basin
#

ow nice, was about to test it myself

#

thanks for confirming it, I wasn't sure

#

the Inverse seems pretty useless then

keen dew
hazy crypt
#

Hi guys, Im trying to make a rolling ball. I have it looking exactly as I want but when the ball rolls, it doesnt have any friction (stays in place)

#

heres the code

#

Im just rotating it, is that the issue?

keen dew
#

yes

hazy crypt
#

And rotating it doesnt apply physics?

#

How do I apply a rotary force?

hazy crypt
#

Thats fantastic, thanks mate.

keen dew
#

rb.transform doesn't affect the rigidbody, it's exactly the same as just accessing transform directly

hazy crypt
#

Thats interesting, I assumed the rd stodd for rigidboyd

#

damn my spelling lol

keen dew
#

It does, but rb.transform is a reference to the object's transform. Rigidbody doesn't have its own transform

hazy crypt
#

Okay so the rigidbody is just a component, the object has the tyransform?

keen dew
#

right

hazy crypt
#

Sort o makes sense

#

Ill understand more as I play with it

#

Thank you!

keen dew
#

...what?

timid saffron
#

It moves the player forwrd

keen dew
#

What does?

timid saffron
#

transform.position = Player.transform.position+ offset;

#

this is for camera to follow player

keen dew
#

And how is that related to anything?

timid saffron
#

you said you could do transform.forward = -player.transform.forward

#

why

keen dew
#

Because that sets the transform's forward direction to the opposite of the player object's forward direction

timid saffron
#

I dont understand why I would do that

keen dew
#

That's what you asked for?

timid saffron
timid saffron
keen dew
#

Why tf would you replace the line that moves the transform instead of the one that rotates it?

timid saffron
#

you said see above

#

i thought the code above

keen dew
#

🤦

timid saffron
#

I see this

#

I think this code makes camera turn 180 degrees

keen dew
#

Which is what you asked for

timid saffron
#

actually no

#

yes

#

i see

#

i asked the question poorly

#

your right

#

should have provided more details there

#

I was just trying to make cameras rotation in X axis the opposite

#

but i fixed it

#

what i was trying to do was basically: camera transform.rotation = players rotation (in x axis) * -1

#

you see how camera rotates to left when player rotates to left

#

i tried to do the opposite thats all

#

can you tell me why continousmovespeed works but continuousrotation doesnt?

keen dew
#

Doesn't work in what way?

timid saffron
#

it wont rotate at all

#

by itself

rare basin
#

how did you make sure

#

it doesn't rotate at all

timid saffron
#

Im watching it

#

values are set

keen dew
#

Well for one if you use a fixed vector value it should be rb.AddRelativeTorque

timid saffron
#

it didnt fix it

#

still wont rotate

keen dew
#

You can see the rotation values change

cobalt solstice
#

I know this was a while ago you said this but I've been trying to search for something to fix it myself 😭, you ever managed to figure this one out? Or what the thing causing the error was if you remember?

keen dew
#

make the rotation force bigger

timid saffron
#

i didnt pay attentiont to there

#

i set it to 6000 now it rotates a bit

#

in my mainship if it was like 20 it would go like spinning really fast

#

i didnt quite get why i have to set it to such high values here but nevermind. it works

pastel vector
cobalt solstice
#

I'll have a check ty, the video I'm finding is quite old since they were using WWW rather than UnityWebRequest and in php they were using mysqli rather than PDO

#

So just tryna figure out how to change it

honest haven
#
    {
        RaycastHit Hit;
        
        if (Physics.Raycast(camChild.position, camChild.forward, out Hit, 20f))
        {
            floorBuild.position = new Vector3(
                Mathf.RoundToInt(Hit.point.x) != 0 ? Mathf.Round(Hit.point.x / 2) * 2 : 2,
                Mathf.RoundToInt(Hit.point.y) != 0 ? Mathf.Round(Hit.point.y / 2) * 2 : 0,
                Mathf.RoundToInt(Hit.point.z) != 0 ? Mathf.Round(Hit.point.z / 2) * 2 : 2);

            if (Input.GetKey(KeyCode.B))
            {
                Instantiate(floorPrefab, floorBuild.position, Quaternion.identity);
            }
        }
    }``` hi im trying to place objects at run time im using cinemachine. i can only place items in a circle around me rather then where my mouse is pointing. Or is my code wrong?
hexed terrace
#

You're not using the mouse at all to get a position to place it. From the variable names, you're using the ... camera .. dun dun dun dunnnnn, shocked face

rare basin
#

nothing related to your mouse position here

#

so why would it spawn where your mouse is?

rose galleon
#

Anyone knows any good tutorial for teleporters in metroidvania? E.g. the "horse" in hollow knight?

honest haven
#

yh sorry i see what you mean. I had a child object under my main camera. an i thought that it was coming from that.

rose galleon
honest haven
static cedar
spiral narwhal
#
        [Serializable]
        public record InventorySlot(ItemSO Item, int Amount);

Are records not serialised in the inspector?

slender nymph
#

records aren't even fully supported in the engine

rose galleon
slender nymph
swift crag
#

this looks like what happens when the inspector GUI throws a fit. i'd try selecting something else and selecting your object again

#

ah, but

#

You shouldn’t use C# records in serialized types because Unity’s serialization system doesn’t support C# records.

#

that's more of a showstopper

hexed terrace
spiral narwhal
#

Yes I had to define IsExternalInit, but if I can't use them for serialisation I'll find a a way around this. Just wanted to know if they're not supported or if I'm doing something wrong. Thanks for the heads up 👍

static cedar
hexed terrace
polar acorn
swift crag
#

That is a good point to make

#

It shouldn't be very special.

#

whether you're loading a saved game, going from room to room, or using a teleporter, it's all pretty much the same thing

brave compass
swift crag
#

you change scenes if necessary, and then you position the player correctly

brave compass
# spiral narwhal ```csharp [Serializable] public record InventorySlot(ItemSO Item...

The one liner you're using:

[Serializable]
public record InventorySlot(ItemSO Item, int Amount);

generates (roughly) this class:

[Serializable]
public class InventorySlot
{
    public ItemSO Item { get; init; }
    public int Amount { get; init; }
}

Of course, Unity won't serialize this, because these are just auto-properties. You can add SerializeField to the backing field like this:

public record InventorySlot([field: SerializeField] ItemSO Item, [field: SerializeField] int Amount);

However, this won't work either, because the backing field generated from this will have the readonly keyword because there's no setter, so Unity will still not serialize it.

swift crag
#

good insight (:

spiral narwhal
#

Indeed, thank you!

ripe kayak
slender nymph
#

make sure that your !IDE is configured so it underlines errors for you. then stop trying to use a variable that does not exist

eternal falconBOT
ripe kayak
#

ops

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

public class MainMenu : MonoBehaviour
{
    [SerializeField] GameObject exitPanel;


    public void PlayGame()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }


    public void QuitGame()
    {
        Application.Quit();
    }


    public void Openurl()
    {
        Application.OpenURL("nuh uh");
    }


    public void AreYouSure()
    { 
        QuitPanel.SetActive(true);
    }


    public void AreYouSureNo()
    {
        QuitPanel.SetActive(false);
    }



}
#

here we go

#

guys what should i do

slender nymph
ripe kayak
#

oh u meant me

slender nymph
#

yes

rocky canyon
ripe kayak
#

but how

ripe kayak
#

im trying to follow this video

slender nymph
#

follow the bot's instructions to get your code editor configured. that is step 1. it is a requirement to have configured tools to get help here

polar acorn
eternal falconBOT
ripe kayak
#

its so confusing ngl

#

i installed it

slender nymph
#

did you follow all of the steps for the code editor you are using?

rocky canyon
#

just follow it one step at a time.. its really not all that difficult

#

when its correct you'll see Assembly-CSharp at the top

polar acorn
ripe kayak
spiral narwhal
#
public event Action<Inventory.InventorySlot[]> OnInventoryLoaded;

How do I allow outside classes to Invoke the event without using a function?

slender nymph
# ripe kayak

there you go. now stop trying to use a variable that does not exist

slender nymph
polar acorn
# ripe kayak

Okay good. Now you should be able to solve the problem. There's no such thing as QuitPanel

ripe kayak
#

the video says ```quitPanel````

spiral narwhal
slender nymph
# ripe kayak the video says ```quitPanel````

that's cool. you do not have a variable with that name in your code. nor are you atttempting to use a variable with that name. you are trying to use QuitPanel which does not exist in your code

slender nymph