#💻┃code-beginner

1 messages · Page 192 of 1

storm imp
#

fast in what way?

rich adder
#

RAM?

#

SSD?

faint sluice
summer stump
#

Can it leap tall buildings with a single bound?

storm imp
rich adder
#

jesus

storm imp
rich adder
#

dont expect stellar speeds with such a mediocre cpu

storm imp
rich adder
storm imp
rich adder
#

smart

swift crag
#

that will slow things down a fair bit

rich adder
#

I have a ryzen 7 1700x and Im barely hanging on, there is no way your CPU can handle much better anyway

#

ryzen 3 is low level tier

swift crag
#

also, what do you mean by "busy"?

If you're talking about the popup after changing your scripts, Unity has to recompile all of your code when you edit it

rich adder
#

yeah now imagine that on a mechanical drive

vague dirge
#

Oh no correction I didn't express myself well, little lapsus, I meant between transform.position.y and transform2.position.x So it'd be the global Srt(x^2 + y^2) formula, and I'm searching a method. Or I guess I'd use Vector2.Distance(Vect3(0, transform.position.y, 0), Vect3(transform2.position.x, 0, 0)) ?

rich adder
#

then you wonder why it takes long lol

storm imp
faint sluice
swift crag
#

You can set unity to only refresh on command

rich adder
faint sluice
swift crag
#

Auto Refresh in the Asset Pipeline section of your preferences

#

(not project settings)

faint sluice
rich adder
storm imp
noble summit
faint sluice
swift crag
#

No. It reloads when you tell it to.

rich adder
swift crag
noble summit
faint sluice
swift crag
#

Oh, that's the suggested maximum line length

#

It's going to be 80 or 120 characters or something

rich adder
swift crag
#

I don't know exactly where to toggle that

fringe plover
#

why when i Instantiate prefab collider and my script components are off?

rich adder
fringe plover
#
  private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.TryGetComponent(out Mergeable idfk))
        {
            if (idfk.level == level)
            {
                rollMeRand();
                if (idfk.rand > rand)
                {
                    if (nextBall != null)
                    {
                        GameObject B = Instantiate(nextBall);
                        B.transform.position = transform.position;
                    }
                    Destroy(gameObject);
                }
                else if (idfk.level == level) Destroy(gameObject);
                else Destroy(gameObject);
            }
        }
    }
    public void rollMeRand()
    {
        rand = Random.Range(1, 1000);
    }```
noble summit
rich adder
wintry quarry
fringe plover
storm imp
swift crag
#

I'm not sure how to disable it in the mac visual studio though

wintry quarry
fringe plover
#

no

wintry quarry
#

You sure? Show some screenshots

swift crag
#

A component will disable itself if it throws an exception in Awake or Start

#

(i think both?)

wintry quarry
#

I think Awake and OnEnable but yes, that.

#

Show which components are disabling?

fringe plover
wintry quarry
fringe plover
#

yes

wintry quarry
#

I mean show a screenshot

rich adder
noble summit
fringe plover
rich adder
wintry quarry
# fringe plover

Can you not crop the screenshots? Just show the full unity window

#

because it's unclear which object is selected here

fringe plover
#

lemme record

noble summit
storm imp
# rich adder show me where you call ReturnToMenu

I posted it on r/unity and somebody commented this

At a first glance, in your LoadSite method, it looks like you're setting the selected site to active, but you're never disabling the others. So if the first one that loads is in front of the others, it seems like you'll never be able to see them since the first one will be covering them up.

And then like another commenter pointed out, in the menu method, you've got the for loop to disable all three sites, but you're passing in 1 as the index instead of 'i', which will always just disable only the one site.

storm imp
wintry quarry
rich adder
noble summit
#

in vscode 5 seconds after opening all the code turns the same color and gives me an error "Project system initialization finished. 0 project(s) are loaded, and 1 failed to load."

rich adder
# storm imp oh is it?

I think your problem might actually be ReturnToMenu() unless you can show me its fine,

fringe plover
wintry quarry
#

those aren't prefabs

#

prefabs are the things in your project folder

#

You should have a separate script that instantiates things

fringe plover
#

oh ok...

rich adder
sour yew
#

hey guys. why these brushes dont work? i click on them, but my mouse cursor doesnt change. any help?

rich adder
storm imp
rich adder
#

screenshot sitesnow 2 active in scene

storm imp
rich adder
rich adder
#

So the code is working

#

you just put the same picture for Site Snow 2

#

this whole time

storm imp
faint sluice
#

Got trolled hard

languid spire
#

yep, same material

rich adder
# storm imp

ok all three objects are being toggled correctly you just got the same material/texture

storm imp
rich adder
#

are you forreal?

summer stump
storm imp
summer stump
#

And you told it to use the same photo

rich adder
#

because you put the samee tetxure.

summer stump
languid spire
#

yes, because you told them to

storm imp
summer stump
storm imp
languid spire
#

turning your computer on

#

is where you went wrong

rich adder
#

that makes no sense

#

mehh at least the code was working

dusty silo
#

I am using the following line to create a Vertex.
Vertex v = Instantiate(Resources.Load("Prefabs\\VertexPrefab"), pos, Quaternion.identity) as Vertex;
This compiles fine, but throws a runtime error. For some reason, v is null.
Any idea why? If so, you you explain what the line is doing so I can understand?
Thanks.

rich adder
buoyant knot
#

isn’t that backwards

rich adder
#

ye should just be /

#

and is Prefabs inside a Resources folder?

dusty silo
#

That path seems to work fine

dusty silo
summer stump
#

The path is wrong. Nav just linked the docs

rich adder
# storm imp

its fine , it isnt relevant now, we already found the cause. The code was never a problem

storm imp
summer stump
# storm imp

Just. Put. Different "photos" for different spheres.
Instead of the same one.

rich adder
#

yes make 3 materials

#

one with each photo

storm imp
summer stump
#

And yes, of course you do
Just like the tutorial did

rich adder
#

just apply the material to them if you have the spheres already

fringe plover
#

can someone help? I cant figure out how to spawn one, cuz when 2 objects collide the both try to spawn a new one

dusty silo
# summer stump Why would you want to escape it? It is necessary

The path was fine. I am still getting the runtime. Here is the entire method.

        Vertex v = Instantiate(Resources.Load("Prefabs/VertexPrefab"), pos, Quaternion.identity) as Vertex;
        //Vertex v = g as Vertex;
        Debug.Log($"Vertex is null: {v == null}");
        v.setCamera(c);
        return v;
    }```
fringe plover
summer stump
summer stump
fringe plover
#

!code

eternal falconBOT
dusty silo
#

I used that exact path many times and it successfully loads the resource, the problem is the same.

eternal falconBOT
fringe plover
swift crag
#

I presume you're getting a reference to the game object

#

You can't cast that to a Vertex.

#

If you want a Vertex reference, then ask for one

#

Resources.Load<Vertex>(...)

dusty silo
#

Will that still instantiate the object?

storm imp
swift crag
#

If you Instantiate a component, the entire game object is copied

#

You receive a reference to whatever it is you instantiated.

#

GameObject can't possibly cast to Vertex

rich adder
polar acorn
swift crag
#

A game object with a Vertex component on it isn't a Vertex

#

It's just a game object that has a Vertex on it

glad swallow
#

My character Controller is coliding with triggers, how do I stop this from happening?

dusty silo
#

Thanks. I didn't know Load could be given a class.

swift crag
#

It isn't. Those must not be trigger colliders.

glad swallow
swift crag
glad swallow
#

currently using this to see if the character is groudned

swift crag
#

Both non-generic methods just return a UnityEngine.Object

storm imp
swift crag
#

The generic methods let you get a specific type right off the bat

swift crag
#

so of course all three renderers look the same

#

don't do that

summer stump
fringe plover
rich adder
#

you have to Unpack the FBX

#

apply new material, then do the next

swift crag
glad swallow
swift crag
#

that'll work just fine

swift crag
storm imp
fringe plover
# glad swallow thanks

int layerToIgnore = LayerMask.GetMask("NotGround", "Player", "Ignore Raycast"); int layerMask = ~layerToIgnore;

summer stump
swift crag
#

I would suggest two things:

  • Specify which layers to hit, as shown above
  • Use QueryTriggerInteraction.Ignore to ignore all triggers
polar acorn
swift crag
# storm imp FBX?

These three objects are instances of the same prefab.

If you assign a material to the prefab in the inspector, all three will get the same material.

#

Do not do that. Assign a material to each object in the scene, individually.

buoyant knot
#

or assign the material to the prefab, so everything tied to the prefab will get that material

swift crag
#

that's the exact problem

#

the three objects are supposed to have three different materials on them

#

they don't. they have the same material

buoyant knot
#

oh

#

that’s weird

buoyant knot
#

you see how the name of the gameobject is blue

swift crag
#

it sounds like you have basically no idea what any of these words mean. you desperately need to learn how Unity works before you try to make something in it

storm imp
summer stump
# storm imp prefab?

Every time you hear a new word. You repeat it with a question mark. Please TRY to learn for yourself every once in a while. Google "unity prefab" see what it means

raven hill
#

Hello, I don't know why this script doesn't work. I know it gets the target position right, but doesn't add the force.

summer stump
#

Also, PLEASE stop your project and go through the "unity essentials" pathway here
!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

buoyant knot
#

it’s tied to a stock gameobject file, called a prefab

#

so if you make edits to the prefab, it will connect the changes

summer stump
# raven hill

AddForce doesn't take a position
It takes a directional vector

buoyant knot
#

if you do not want this to be the case, you should unlink the gameobject in the scene from the prefab

#

you will know an object is linked when name is blue, and not linked when name is white

summer stump
#

Yes, see how that says m_newForce?
Oh, it's gone

raven hill
#

yea

summer stump
#

target - transform.position gives you a direction

polar acorn
# storm imp prefab?

Stop. Stop everything. You need to learn literally anything about the program you are using. !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

summer stump
#

Then you can normalize that and multiply it by a force if you want

raven hill
#

thx

polar acorn
#

Do not attempt to work on this project any further until you at least know what the program you are using even does

timid saffron
#

Im trying to make ship rotate 180 degrees in y axis if its z position is less than 200 and start going +z in position instead of going - as in (0, 0, -1)

#

problem: its position in z wont change at all

#

what Ive tried: put if statement in different places in update

#

changed private bool shiprotate to true and false

cosmic quail
storm imp
#

I don't know what I did but it works now

unreal imp
#

No,its the muzzle from the gun where it shoots the bullet

timid saffron
#

it only rotates the ship in z axis continously

cosmic quail
#

did u try that

timid saffron
#

"transform.position = transform.position + new Vector3(0, 0, -1 * seperationSpeed * Time.deltaTime);
transform.Rotate(Vector3.forward, rotationSpeed * Time.deltaTime, Space.Self);"

#

these lines work as intended

#

problem is in if statement

#

but let me try

cosmic quail
cosmic quail
#

wait thats position not rotation

summer stump
#

And we know what you did, you added the right materials to the different spheres

rich adder
timid saffron
#

ship is supposed to rotate and come back if its z value is lower than 200 at the oppsoite z position

#

In if statement (0,0 "-1") I already set Z to negative value

#

and in regular update it is positive 1

cosmic quail
timid saffron
#

you mean like this?

cosmic quail
# timid saffron

wait also currently if it completes the if statement it also does the other one. is that intended? should it be if else

timid saffron
#

I will try to break it down:
" transform.position = transform.position + new Vector3(0, 0, -1 * seperationSpeed * Time.deltaTime);":
here. the ship goes in negative Z direction continously
" transform.Rotate(Vector3.forward, rotationSpeed * Time.deltaTime, Space.Self)" this is not related to position so im skipping it.

    if (transform.position.z < 200 && !shipRotate180)
    {
        transform.Rotate(Vector3.up, 180f, Space.Self);
        shipRotate180 = true;
        transform.position = transform.position + new Vector3(0, 0, 1 * -seperationSpeed * Time.deltaTime);
    }

here. if ships Z value is less than 200 its supposed to rotate 180 degrees then move in the +Z direction now instead of the regular -Z

timid saffron
wintry quarry
#

It's called "C Sharp"

rich adder
#

tell me you're zoomie without telling me ur zoomie

unreal imp
#

Ahhh you re talking about instead of 0.5,0.5 I replace it by the bulletspawn pos xd

timid saffron
#

John do you want me to record a video and tell what Im trying to achieve?

south sky
#

Yo Im confused, if you return a method, would the returned method run?

signal bronze
#

Whats wrong in this code? Like, the Menu is still visible when I run the scene.

#

And nothing happens when i press ESC

timid saffron
#

Ive also tried this

modest dust
summer stump
# raven hill

Ah, it's the rigidbody. You need to either drag in the rigidbody component via the inspector (which you cannot, because it is private)
Or call GetComponent<Rigidbidy>() in awake

https://unity.huh.how/references

raven hill
#

I have it

#

unless its set up wrong

south sky
#

Yo Im confused, if you return a method, would the returned method run?

languid spire
#

no

south sky
#

Shit

#

Thanks tho

summer stump
# raven hill

You have it, but it is not referenced. Simply having it does nothing.

Also, you need the type to be Rigidbody2D, not just Rigidbody

rich adder
south sky
# rich adder what are u trying to do

I have a method for a script and it says there is an error that not all paths return a value (I used an if statement with no else) so i said else return GetMethod(); incase there is an error

summer stump
# raven hill

To clarify, it doesn't know WHICH rigidbody you want to add force to. There are times you want to add force to rigidbodys on different objects.
The compiler will rarely ASSUME anything, so it will NOT assume the rigidbody you're talking about is the one in that screenshot. You need to explicitly tell it that

rich adder
south sky
#

a gameobject

rich adder
south sky
modest dust
south sky
#

how can you return the return value

#

What would be the return value?

rich adder
#

also this would be like 2 lines with an Array..

south sky
rich adder
#

should learn about arrays

#

they are vital in coding

south sky
#

Cool, where do you recommend to learn

#

You got a yt channel with everything lol

rich adder
rich adder
#

I expect my watchers to have somewhat understanding of c#

south sky
#

Just like einstein said, if you cant explain it simply, you failed to understand

rich adder
summer stump
# south sky I have no idea what that means lol😭

Think of a method call as simply moving to a different spot. It is no different than having the body of the method right where you call it.

public void Start() {
  bool something = MyMethod()
}

public bool MyMethod() {
  return true;
}

Is the same as

public void Start() {
  bool something = true;
}

The return just tells it to put the value where the method call is

rich adder
#

I dont have the "teacher" personality

south sky
rich adder
modest dust
south sky
south sky
#

Thanks for explaining

#

But would that also work for game objects?

south sky
broken arrow
#

Oof

modest dust
#

Fair enough

rich adder
#

a month is a decent amount of time to learn some basics lol

south sky
#

I got other classes as well untop of this

summer stump
south sky
#

Omds

#

I realised i could have done this so much easier

summer stump
#

I will say that I almost never find myself wanting to store a gameobject, and I prefer storing COMPONENTS like scripts of rigidbodies and stuff
Because all of that can access their attached gameobject with the .gameObject property

modest dust
#

Yeah, learning some C# basics would be probably a good idea if you just came to this realisation..

rare basin
#
int armyNumber = (int)units[i].UnitArmy;
turnOrderUIData[i].unitArmyText.text = $"{armyNumber}";
Debug.Log(armyNumber);
public enum UnitArmy
{   
    ArmyOne = 1,
    ArmyTwo = 2
}

How come, the debug log prints 0 and 1 only, instead of 1 and 2?

south sky
modest dust
south sky
#

Didnt expect people here to be so nice

sterile radish
#

hi, im making a tower defense game. i wanted to make something where whenever you select a tower to build, an objects spawns with the icon of the tower u are currently trying to buil to inicate to the player what they pressed.
buildmanager:
https://hatebin.com/ahszcovimb
shop:
https://hatebin.com/zdcafhfplc

hollow lark
#

How do you guys learn game mathematics and apply that into a game engine? (I'm very new to this)

rich adder
#

oh shite math...

storm imp
#

now how would I share this virtual tour?

timid saffron
#

my ship wont start moving in Z direction

#

i know there are a lot of if and elses

rich adder
eternal falconBOT
#

mad No

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

timid saffron
#

oka

#

what was the thing that you use when sending codes it was something like ''

modest dust
#

!code

eternal falconBOT
rich adder
timid saffron
#

first 2 if and else statements work as intended.

#

i made it

#

im basically trying to do the opposite in other 2 ifs and 1 else

#

starting at line 31

#

problem is: ship wont start moving in z direction

rich adder
#

so many magic numbers here

timid saffron
#

wait ill send a video

rich adder
timid saffron
#

when ships z position is less than 200 it rotates 180 degreees and starts going in positive z direction

#

and whats supposed to happen after that is if ships z direction is greater than 800

#

it rotates again and its z position goes down

#

thats all

timid saffron
south sky
#

Do I need to add my script to a gameobject for it to work?

rich adder
ivory bobcat
rich adder
south sky
rich adder
#

Classes are just blueprints to an object

rich adder
#

nah not good enough

#

you need an instance then

#

to call it from

ivory bobcat
# south sky

You've got to reference an instance and call the method of an instance - not the type.

rich adder
#

public GenerateOne generateScript
generateScript.PickAOne()

timid saffron
rich adder
#

!shipRotate180

south sky
modest dust
rich adder
south sky
rich adder
south sky
#

You are one busy fella

#

Hope it goes well

#

Also what does static truly mean?

rich adder
#

thanks! hopefully will make this my job at some point and not deal with drunktards xD

signal bronze
south sky
rich adder
rich adder
signal bronze
rich adder
#

is that intended

signal bronze
#

No

#

Like, its a normal Pause Menu, but the for the guy in the tutorial it works perfectly

rich adder
#

ohh, well the menu is being turned to active if ESC runs

signal bronze
#

its completely in spanish

#

or u askin for ss?

#

May be blind or sum but i think its the same

rich adder
ivory bobcat
rich adder
#

cause this only toggles it on

#

cause your original question "Menu still visible after pressing ESC"

#

there is nothing in this code that hides it..

#

this only makes it appear and pauses the game

signal bronze
noble summit
#

why is my code the same color and not autofilling like normal

signal bronze
signal bronze
rich adder
noble summit
summer stump
# noble summit how

It's just the !ide guides, which I think nav was helping you through earlier?

eternal falconBOT
signal bronze
rich adder
signal bronze
#

ok

#

now its done

#

but when I press H nothing happens

#

why?

#

the code is correct isnt it?

rich adder
signal bronze
#

ok

#

nothing shows up

rich adder
#

then its not running

rich adder
south sky
#

how do I search an array if it has 0s or not

#

But with gameobjects

rich adder
ivory bobcat
#

You'd iterate it and check every element

undone rampart
signal bronze
#

thanks for help but ill go, have a great day everyone

rich adder
south sky
# rich adder if has 0s?

So i originally made an algorithm that will make a solution path and it will fill the whole array with 0s then go through the array and make a snake like path out of 10s 11s and 12s however i converted this to gameobjects for my game in unity and i dont know what to do about the nodes with game objects that have been instantiated

signal bronze
native seal
#

Im having issues with the order of Awake, Start and OnEnable when enabling UI elements any tips?

south sky
#

Wait how do i code "instantiate [GameObject] at every node of the array except for nodes that have previously been instantiated at

rich adder
#

also you need a way to check / define that part in the node

south sky
#

Yh

#

I probably need a 3d array

rich adder
#

dictionary ?

south sky
#

Dictionary?

raven hill
#

Does anyone understand why the projectile is not destroyed after colliding with the player? After I play it, the projectile collider and the player collider touch

rich adder
raven hill
#

Thx

noble summit
#

i tried practically everything

swift crag
#

show us the guide you followed.

noble summit
#

vscode thing

swift crag
#

link me to it. i want to be certain what you looked at.

noble summit
#

and it has worked before

swift crag
#

show me a screenshot of your package manager with the Visual Studio Editor package selected, as well as a screenshot of the External Tools menu

noble summit
#

okay i guess

south sky
#

Yo how do I destroy an already instantiated gameobject?

noble summit
nimble hinge
#

Hi.

noble summit
nimble hinge
swift crag
#

It is deprecated and no longer needed.

noble summit
swift crag
#

You'll need to remove the Engineering feature, then re-install the Visual Studio Editor package.

swift crag
#

Features are found at the top of the Unity Registry section

#

my UI is different, but it's in the same place

south sky
swift crag
#

Features mostly exist to install packages you don't want or need, as far as I can tell

nimble hinge
#

Fen are you actually making a game or just have blank project opened just to help people lol

swift crag
#

annoying UI auto-navigation problems

nimble hinge
south sky
#

Oh cool

nimble hinge
#

if you're using it to destroy

south sky
#

How does that work

nimble hinge
#

not recomended in update

#

Basically

south sky
noble summit
swift crag
#

i don't understand what the problem is

nimble hinge
#

GameObject.Find(pass the name of the object you wish to find)

swift crag
nimble hinge
#

Also note: if it's a child

#

you have to search for parent first

swift crag
#

you already have a reference so I don't understand why you can't just destroy it

nimble hinge
#

and then type its name like this Parent/Child

nimble hinge
south sky
swift crag
nimble hinge
#

Can you provide the script

swift crag
#

if another script needs to destroy the object, then pass that reference from one to the other.

nimble hinge
#

Could not understand randomness you're talking about

swift crag
# noble summit done

now go back to External Tools and make sure it's still set to Visual Studio Code

#

close VSCode, hit Regenerate Project Files, and double-click a script asset to open VSCode again

summer stump
south sky
#

I apologise for my bad code

#

Im new

noble summit
scarlet skiff
#

i instantiate the prefab this way, then destroy the instance specifically yet still get this error

magic pagoda
#

my.. code isnt detecting any errors-

scarlet skiff
swift crag
eternal falconBOT
swift crag
#

follow the VS Code instructions.

swift crag
#

ctrl-shift-P, type "output"

#

should get "Output: Focus on output view" in the palette

#

hit enter

#

switch the Output view to C# and look at the output logs.

rich adder
#

!screenshots

eternal falconBOT
#

mad No

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

nimble hinge
rich adder
#

not code related

nimble hinge
scarlet skiff
nimble hinge
#

But first

magic pagoda
nimble hinge
#

you need to check if it's null or not

noble summit
#

Using dotnet configured on PATH
Dotnet path: /usr/local/share/dotnet/dotnet
Activating C# + C# Dev Kit + C# IntelliCode...
waiting for named pipe information from server...
[stdout] {"pipeName":"/var/folders/x2/xqdmgy2d5yx7ylr6xrf7_r440000gp/T/8e8413c6.sock"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info - 11:30:14 PM] [Program] Language server initialized

rich adder
scarlet skiff
swift crag
# south sky

"It will be the last object spawned"

So if you spawned C, then D, then E, you want to destroy E here?

scarlet skiff
nimble hinge
#

put

if (gameObject != null)

swift crag
noble summit
#

so whats the problem then

south sky
scarlet skiff
rich adder
nimble hinge
# south sky

you can do public GenerateTwo, and pass it in Hierarchy

scarlet skiff
scarlet skiff
#

but it still didnt work

swift crag
#

When you spawn something, add the instance to the list.

rich adder
#

use the ones in !code

eternal falconBOT
swift crag
#

when you want to destroy something, get the last item from the list if it is not empty

scarlet skiff
#

im instantiating it and then putting it in a variable then destroying the variable

nimble hinge
#

Or if you want you can use square brackets

swift crag
south sky
scarlet skiff
swift crag
nimble hinge
#

Can you send a script

swift crag
#
private List<GameObject> spawnedObjects = new();
#

when you spawn something, you'd add it to the list

noble summit
#

dev kit: Starting Spawn .NET server...
Starting Open a solution...
Starting Open a solution with environment service...
Starting Clear environment...
secretStorage: Failed to get secret 'lastPromptDate' from the store. Error: 'Error: Unable to parse decrypted password'
.NET server started and IPC established in 2664ms
Completed Spawn .NET server (3917ms)
Completed Clear environment (4753ms)
Completed Open a solution with environment service (4816ms)
Starting Restore solution...
Completed Open a solution (4836ms)
Completed Restore solution (2688ms)
#getSession: Failed to running method. Error: 'Error: User did not consent to login.'

rich adder
noble summit
#

.net runtime has nothing

nimble hinge
#

And yes fen is correct

scarlet skiff
rich adder
scarlet skiff
south sky
rich adder
#

how is it assigned

nimble hinge
# scarlet skiff

Hey just a question, where do you call this DestroySelf Function

swift crag
summer stump
scarlet skiff
south sky
scarlet skiff
swift crag
# noble summit i dont

I know that the Dev Kit can prompt you to sign in to access paid features...I think it was Dev Kit, at least

rich adder
swift crag
rich adder
#

the instance is prob destroyed by the time you use it

scarlet skiff
swift crag
rich adder
scarlet skiff
#

i see, id have to then copy and paste the same code a couple times

#

or id just make a method for it i suppose

#

aight thanks

swift crag
#

Do you see anything else in the Projects output?

#

here's mine

noble summit
noble summit
south sky
swift crag
#

done

#

a list lets you remember many objects

#

which is relevant if you want to be able to destroy several objects

south sky
#

Ok I see

#

Ima try that

#

Thanks

swift crag
#

and remember to store the instance

#

not the original prefab.

south sky
#

Wait

swift crag
#

go to your project root and delete all of the .csproj files

south sky
#

the instance?

swift crag
#

then do Regenerate Project Files again

swift crag
noble summit
swift crag
#

if you went any higher you'd leave your unity project

nimble hinge
#

Alright

swift crag
#

in general, the "root" is the top-most thing that everything else is a child of

swift crag
#

yes

#

you can also delete the .sln file

noble summit
#

so i just delete assembly-csharp

swift crag
#

I had a weird problem once where Unity was just..appending data to a bad .csproj file

#

i was getting duplicate assemblies

nimble hinge
#

Never understood why unity creates csproj files everytime you copy a project

noble summit
#

ok i deleted it

swift crag
#

the .csproj files contain a description of every file in the project

#

your code editor needs this information

south sky
# swift crag the thing returned from `Instantiate`.

Is ok if you can show me how that would work in code, please. But if you cant, how would you get the instantiated game object because if the gameobject is instantiated and there are other clones of that game object wouldnt destroy destroy all the others?

swift crag
#

Destroy destroys the thing you give it

#

not other random objects that are sort of like it

nimble hinge
#

Wait

noble summit
#

i restarted vscode, and now it says...

swift crag
south sky
#

You want a cookie?

swift crag
swift crag
nimble hinge
#

your code

#

returns gameobject

#

Interesting to say the least

swift crag
#

it's fine

#

probably suboptimal

#

since you probably want something more specific than a game object

south sky
nimble hinge
#

I thought it would return a gameobject type

swift crag
#

well yeah, that's what it does

nimble hinge
#

which meant last object

#

since it's called once

swift crag
#

I don't follow.

#

PickATwo() returns a GameObject. I presume that some other code then passes that to Instantiate to create a new game object.

eternal needle
#

It wouldnt even reach the else if random == 5 or the else statement

nimble hinge
#

Oh wait youre right

swift crag
#

yes, the range is wrong

#

it ought to be Random.Range(0, 6) to produce a number in the set 0, 1, 2, 3, 4, 5

nimble hinge
#

yeah maximum value is exclusive

#

which means it wont be included

#

I don't really know why unity does that but ig

eternal needle
#

This 100% should just be an array/list tho where you can just use the collections length as the max index

swift crag
#

indeed

#

[SerializeField] List<GameObject> choices;

#

it will make your codem uch simpler

swift crag
#

since sequences are zero-indexed, a 10-element list should be drawn with numbers in the range [0, 9]

eternal needle
swift crag
#

What's weird is that Unity makes Random.value inclusive

#

it's [0, 1], not [0, 1)

#

fun edge case for my weighted random function to trip on someday

south sky
nimble hinge
#

so it works like list

#

because if you set list count to 5, the elements only go up to 4

noble summit
swift crag
#

It sounds like the .NET Install Tool extension is failing

noble summit
#

nothing in there

swift crag
#

is this extension installed?

#

it should be if you installed the Unity extension.

noble summit
#

yes

#

Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
Error running dotnet --info: Error: Command failed: dotnet --info
is in C#

swift crag
#

okay, so it tried to use the extension

#

What follows that line in the C# output?

noble summit
#

/bin/sh: dotnet: command not found

swift crag
#

gimme the entire C# output log in a pastebin

noble summit
#

why pastebin

swift crag
#

because it's probably kind of long and I don't want to clutter the chat more

#

!code any of these sites is fine

eternal falconBOT
noble summit
#

what about a ss

swift crag
#

you could've just sent it in like 15 seconds

#

i'm not sure why we're talking about this at all

noble summit
swift crag
#

okay, all of that seems okay, although the errors from sh are a bit weird (I don't see those on my end)

#

also on a mac

#

I'd give the machine a restart for kicks

noble summit
#

tried that and nothing happened

#

earlier

south sky
swift crag
#

no code is being "instantiated"

south sky
swift crag
#

you're passing a GameObject to Instantiate. Unity copies the object (and all of its components) and returns a reference to the new instance of the game object.

#

And yes, the new object is placed into the active scene.

proper bobcat
#

Not sure why I am getting this message

MissingReferenceException: The object of type 'SphereCollider' has been destroyed but you are still trying to access it.

Your script should either check if it is null or you should not destroy the object.
_TowerDefense.Towers.Tower.SetSphereColliderActive (System.Boolean shouldEnable) (at Assets/_TowerDefense/Scripts/Towers/Tower.cs:25)

The towers are never destroyed in the game atm, neither are the sphere colliders that are attached

south sky
#

Ok fine thanks

swift crag
#

ah, I think I can guess what it is

#

does OnGameStateChanged fire as the game is quitting?

swift crag
#

During shutdown, everything gets destroyed

#

and I believe this happens immediately, rather than..later, at the end of the frame

proper bobcat
#

But this is when I click play

swift crag
#

Do you have Domain Reload disabled?

proper bobcat
#

Yupp

swift crag
#

GameManager.GameStateChanged is static

proper bobcat
#

ah....

swift crag
#

Its contents are not reset between play sessions, because you've disabled Domain Reload

proper bobcat
#

Gotcha

swift crag
#

The fix is to unsubscribe as the Tower is destroyed

#

I've dealt with this a fair bit

rich adder
#

always cleanup your events anyway static or not

swift crag
#

You can safely unsubscribe from an event even if you've never subscribed to it

#

yeah, this would still cause errors even with Domain Reload

#

as soon as a tower got destroyed

#

do it in OnDestroy and you should be good

proper bobcat
#

Oh I have been using OnEnable and OnDisable

#

Is destroy better?

north kiln
#

You should 100% be resetting in [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] if you're not already

swift crag
#

OnDisable also runs during destruction, so it would be acceptable

swift crag
proper bobcat
swift crag
#

I use it to wake up my singleton GameController, which then fires up other parts of the game

north kiln
proper bobcat
#

I knew domain reload would catch up to me sometime

#

I like my game to load fast

#

But yes I understand it comes with implications

north kiln
#

Everyone I recommend it to I recommend to thoroughly read those docs

proper bobcat
#

Will do

hoary light
#

yo i need some help

#

the inspector says this

slender nymph
#

make sure you have saved

hoary light
#

but as seen here

slender nymph
#

and configure your !IDE

eternal falconBOT
hoary light
#

my code is very different

hoary light
#

and when i open the program thrue unity it shows the same

#

but on the inspector its different

slender nymph
#

then you have either turned off the automatic asset refresh and need to manually refresh it. or you are looking at the wrong file

hoary light
#

and now my player dosent move

slender nymph
#

ctrl+R in the unity editor. also check Edit > Preferences > General to see if you have disabled that setting

hoary light
#

im preety sure im looking at the same code

slender nymph
# hoary light

this also does not prove that you are looking at the same file. just that they have the same name

swift crag
#

like from player_movement.cs to Player_movement.cs

hoary light
hoary light
swift crag
#

that doesn't answer my question

#

did you change the capitalization after creating the file?

swift crag
#

okay, so that's not relevant, then

slender nymph
swift crag
#

I've seen unity get very confused by a case change on case-insensitive filesystems.

hoary light
#

i tryed the ctrl R thing

#

same exact outcome

slender nymph
#

and you pressed that in unity, right?

hoary light
raven hill
#

I don't understand the issue with this code

slender nymph
hoary light
#

in vs or in unity?

rich adder
eternal falconBOT
rich adder
#

please configure your ide

slender nymph
#

also yes, get your IDE configured

young lava
#

Is there a good way to rename scripts in unity? I was just wondering if there is a feature or something that allows you to change the name of the script and all references to it at the same time.

formal arch
#

could anyone tell me why this isnt working? the enemy has the tag, on the same layer, the ray is hitting the enemy as the something was hit debug is firing off but it won't detect it's hitting the enemy.

hoary light
#

and yes the script is connected to my sprite

north kiln
rich adder
north kiln
#

Or use the debugger

hoary light
slender nymph
#

if there are no compile errors and you have saved the code and ensured that the assets have been refreshed and you still don't see the right code in the inspector when you select the script in the project folder then you are looking at the wrong file

north kiln
#

Or, errors have been hidden in the console

hoary light
#

same name in the same folder

slender nymph
#

ah yeah, i gotta stop assuming that people aren't just hiding their errors

slender nymph
hoary light
#

this is my first time using unity so im kinda new to this

#

im running the project rn theres litterally NOTHING here

#

thats what weirds me out

south sky
#

How often should one use Debug.Log?

slender nymph
#

as often as you need to print something to the console

rich adder
#

then use both

south sky
#

Cool

hoary light
#

full screen of both the file tab and console tab

slender nymph
#

because it's either that or you have not actually saved and refreshed the assets

hoary light
#

so thats aswell off the list

slender nymph
#

screenshot your entire vs code window

slender nymph
#

entire window

hoary light
slender nymph
#

that file is not saved

north kiln
#

well, it's currently unsaved

hoary light
#

oh

#

im a moron lol

slender nymph
#

literally the first thing i said to do

hoary light
#

sorry im new to unity lel

raven hill
north kiln
#

and why is the highlighting so bad, is it just partially unconfigured?

hoary light
#

now how do i save it lol?

hoary light
slender nymph
hoary light
#

ok

slender nymph
hoary light
#

ok anyways

#

how do i save this

#

im actually asking

formal arch
slender nymph
hoary light
#

i did it

#

lol

#

EXCELLENT new errors -_-

slender nymph
#

get your !IDE configured then fix your spelling mistakes

eternal falconBOT
hoary light
#

ok ty alot for the help and sorry for making yalls lives kinda hard lol

north kiln
# hoary light huh

It literally tells you to edit your messages instead of posting like this

raven hill
slender nymph
#

before i provide any more details, is your IDE configured yet?

raven hill
#

I think so

slender nymph
#

if you are unsure then screenshot your entire IDE window and send it here

raven hill
slender nymph
#

that is unity

raven hill
rich adder
raven hill
fringe cedar
#

Could I get any help with Cinemachine Cameras? or does anyone have alternatives for a 3rd person camera!?

slender nymph
#

also if you have visual studio installed, you should really consider just using that instead of vs code

raven hill
rich adder
#

chances are you scripts are still tied to VS

raven hill
#

I did

slender nymph
slender nymph
# raven hill I did

did you install the c# extension? and if you only just installed it, have you restarted your computer since doing so?

lone sierra
#

i have a question about my code

slender nymph
lone sierra
#

this is where u ask?

slender nymph
#

what does the channel description say?

rich adder
#

Cause last time VSCode complained for me that's why I do it

raven hill
#

Not sure tho

rich adder
raven hill
#

My files are C#

raven hill
slender nymph
# raven hill Not sure tho

wdym you are not sure? installing it is part of the configuration guide and surely you followed that, right?

lone sierra
#

is there a fix for making the bullet shoot in the direction of the player?

rich adder
ivory bobcat
eternal falconBOT
rich adder
#

isn't .up a direction ?

ivory bobcat
#

Large code blocks should not be placed inline

raven hill
#

Thx tho

rich adder
#

maybe its already working..

raven hill
rich adder
#

its working

ivory bobcat
rich adder
raven hill
#

Thanks

rich adder
#

unless OP had Global on

raven hill
#

I'm gonna go to sleep

ivory bobcat
#

The name implied it was a point

south sky
#

Would bar still exist and would the prefab/gameobject be instantiated into the scene in unity?

GameObject foo = Instantiate(prefab);
GameObject bar = foo;

Destroy(foo);
swift crag
#

Both foo and bar refer to the same C# object

#

They're two variables that both happen to refer to the same thing

rich adder
scarlet skiff
# raven hill

you can use mathf.clamp() instead of if (shield>shieldCap)

not much more effective but ye

river glade
#

Hi everyone, I definitely made a bit of confusion in the calculations, I use the character controller, and my aim was to add gravity to the character and so far so good, my problem is when I click play on my character instead of standing with my feet on the ground, it goes up (but immediately stops) on the y axis
(I hope I've made myself clear, if so I'll make a clip)
this is code:
https://pastebin.com/FWvbz0M6

ivory bobcat
#

Instantiate creates one instance. You're referring to the instance using foo and bar.

swift crag
#

you're adding gravity to your movement vector after you reassign movement

#

that's not accomplishing anything

#

I'm guessing your character goes up because the character controller's "Center" property is wrong

#

make sure the capsule is resting on the ground, not stuck in the floor

swift crag
#

god those ragdoll colliders are so broken

river glade
#

the character's position is fine, it's not stuck in the floor

river glade
swift crag
#

oh, that's just the skin width

#

the character controller has a little bit of extra margin around it

#

I'd suggest just offsetting the controller so that it's 0.08 meters above the ground

#

You can also reduce the skin width of the controller. I haven't really seen any catastrophic problems from doing that yet

#

but it nominally could make collision worse

native seal
#

anyone have an idea what this error could be? PlayerEquipment is not being destroyed

Your script should either check if it is null or you should not destroy the object.
UnityEngine.Component.TryGetComponent[T] (T& component) (at <30adf90198bc4c4b83910c6fb1877998>:0)
PlayerEquipment.UpdateWeapon (Weapon weapon) (at Assets/_Scripts/Player/PlayerEquipment.cs:22)```
swift crag
#

well, it is

#

unity doesn't show you random error messages for fun

#

perhaps one PlayerEquipment still exists, but another has been destroyed

native seal
#

its still on my player when the error is showing though

#

could it be because of

    {
        equippedItems = new Equipment[10];
        foreach (ItemStack equip in gearInventory.GetItemList())
        {
            EquipItem((Equipment)equip.item);
        }
    }```
swift crag
#

that doesn't matter if something else is trying to access a destroyed instance

native seal
#

where i reset the array

swift crag
#

share the entire script: !code

eternal falconBOT
native seal
swift crag
#

okay, so UpdateWeapon is being called on a destroyed instance of PlayerEquipment

#

You get this exception when you attempt to call TryGetComponent on the PlayerEquipment

meager raptor
#

anyone help appreciate it

swift crag
#

perhaps in the Start method of UnityHandler?

meager raptor
#

yeah I did

#

ill show you

swift crag
#

then it's probably happening after you try to use instance in another component's Start method

#

Assign it in Awake instead. That runs before any Start method will.

meager raptor
native seal
swift crag
#

Log the object before you try to call UpdateWeapon on it

#

do it like this:

#
Debug.Log("The equipment: " + myPlayerEquipment, myPlayerEquipment);
#

If myPlayerEquipment is valid, clicking the log entry will take you to it

#

You could also log this to find out who is trying to call UpdateWeapon on the PlayerEquipment

#

I'm guessing you have a stray component somewhere

north kiln
native seal
#
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Component.TryGetComponent[T] (T& component) (at <30adf90198bc4c4b83910c6fb1877998>:0)
PlayerEquipment.UpdateWeapon (Weapon weapon) (at Assets/_Scripts/Player/PlayerEquipment.cs:22)
PlayerEquipment.EquipItem (Equipment equipment) (at Assets/_Scripts/Player/PlayerEquipment.cs:71)
PlayerEquipment.UpdateEquipped () (at Assets/_Scripts/Player/PlayerEquipment.cs:51)
PlayerStats.UpdateStats () (at Assets/_Scripts/Player/PlayerStats.cs:93)
PlayerStats.LevelUp () (at Assets/_Scripts/Player/PlayerStats.cs:52)
PlayerLevel.LevelUp () (at Assets/_Scripts/Scriptable Objects/SO Scripts/Entities/PlayerLevel.cs:31)
PlayerLevel.AddExperience (System.Int32 amount) (at Assets/_Scripts/Scriptable Objects/SO Scripts/Entities/PlayerLevel.cs:25)
PlayerStats.AddExperience (System.Int32 amount) (at Assets/_Scripts/Player/PlayerStats.cs:46)
UnityEngine.Events.InvokableCall`1[T1].Invoke (T1 args0) (at <30adf90198bc4c4b83910c6fb1877998>:0)
UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) (at <30adf90198bc4c4b83910c6fb1877998>:0)
ListenerBase`3[T,E,UER].OnEventRaised (T item) (at Assets/_Scripts/Game Events/Event Listeners/ListenerBase.cs:26)
EventBase`1[T].Raise (T item) (at Assets/_Scripts/Game Events/Events/EventBase.cs:13)
Enemy.Die () (at Assets/_Scripts/Enemies/Enemy.cs:87)
Enemy.TakeDamage (System.Int32 damage) (at Assets/_Scripts/Enemies/Enemy.cs:40)
ExplosionProjectile.OnTriggerEnter2D (UnityEngine.Collider2D collision) (at Assets/_Scripts/Equipment Logic/ExplosionProjectile.cs:23)```
#

it happens when I level up

north kiln
#

Show the event you're subscribed to

native seal
#

its just an int event for xp

north kiln
#

okay, and how is it declared

native seal
#

the issue isnt the event

north kiln
#

Okay then, good luck with the issue that you apparently understand

native seal
#

the error starts happening when I level up which causes PlayerStats to reload all of the gear and update the weapon

#

the event just adds xp

#

and it works

south sky
#

Unity wont allow me to add scripts and i cannot put gameobjects with the scripts what is an alternative?

north kiln
native seal
#

this is the event

south sky
north kiln
native seal
#

yes

#

and it also occurs in build

north kiln
#

You're likely not resetting or unsubscribing from your event

#

If it's occurring in a build then is it happening after a scene change?

native seal
#

i think youre right

#

yep fixed, thank you

north kiln
#

I am unsure how your event script works, but if it's got statics then it needs to be cleaned up in [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
As it's an asset, if it's not unsubscribed from it'll persist between scenes, which will cause the issue

carmine sierra
#

if an object already has velocity, will making the gravity scale be 0 stop it in it's place

native seal
#

the issue wasnt with my xp event it was a c# event i forgot i had

weary finch
#

How does the SphereCastNonAlloc work? Like it doesn't return the closest object to be found, how can I make it work as such?

carmine sierra
#

what's this error?

timber tide
#

with a colliders

weary finch
#

I was expecting the results to be sorted by distance, but its not the case, and the documentation also says that

meager raptor
#

does anyone have an idea on why it wont let me drag the game objects to the slots?

timber tide
meager raptor
rich adder
rich adder
# meager raptor

which gameobjects, these cropped out photos are not helpful at all

rich adder
meager raptor
#

ah okay that makes sense thanks

#

is this a code error or unity error

#

it even spelt commander wrong

summer stump
#

unitType.Commander, not Commander by itself

meager raptor
#

u sure? it only appeared for commander not the other units

summer stump
#

Wait, your trying to set Unit to an enum?

meager raptor
#

ye

slender nymph
# meager raptor

where is the string coming from because it certainly isn't related to that enum

summer stump
#

How is the compiler supposed to set Unit type to be an unitType enum?