#VS Code Unity Extension Problem

1 messages · Page 1 of 1 (latest)

haughty dust
spiral aurora
#

@haughty dust i didn't even notice this tiny little thing

#

i had to squint really hard 🤣

haughty dust
#

💪 thats the new stuff

prime geyser
#

i deleted it and re-opened it btw

#

nothing changed

haughty dust
#

it still asking you about multiple solutions?

prime geyser
#

nope

haughty dust
#

ok , and you reneged project files before opening?

prime geyser
#

oh

spiral aurora
#
  • did u delete all the .proj and the sln files
  • did u regen or open thru Unity
  • are you sure ur vseditor plug-in is updated to 2.0... in the package manager
haughty dust
#

also double check VSCode editor package is removed from Package Manager

spiral aurora
#

^ yea, that too

haughty dust
#

that could cause issues lockin on

prime geyser
spiral aurora
#

well that looks like mine..

prime geyser
#

imma do it again

spiral aurora
haughty dust
#

it should be working if it says loadeded

prime geyser
haughty dust
#

also did you check if VSC editor package was in package manager in unity?

prime geyser
haughty dust
#

good.

#

double click a script from it

#

maybe it will load it properly

prime geyser
haughty dust
#

open yes

spiral aurora
#

😐 lol

prime geyser
#

i restarted it, still doesn't work

spiral aurora
#

what are we trying to do.. was it just his explorer being wrong?

haughty dust
#

no underlines

spiral aurora
#

oooOOo

#

ok

haughty dust
#

does it show the files?

spiral aurora
prime geyser
haughty dust
prime geyser
haughty dust
#

do you not have the same solution explorer?

prime geyser
#

and the solution is still open

haughty dust
haughty dust
prime geyser
haughty dust
#

expand assembly

#

find yout script in Assets

#

double click it

#

check bottom bar while anything is loading

prime geyser
haughty dust
#

i changed my colors a while ago

#

verify by typing Rigid

spiral aurora
#

hover it.. does it tell u anything?

haughty dust
#

if it shows rigidbody then your good

spiral aurora
#

yea use rigidbody

#

good test lol

prime geyser
#

let's goo

#

but one problem

haughty dust
#

where is context box

spiral aurora
#

i think thats Codium

#

this is what shoulda happened

prime geyser
haughty dust
#

intellicode

prime geyser
haughty dust
#

ok

#

good

spiral aurora
#

good

spiral aurora
#

and this is technically an error.. b/c its not complete

haughty dust
#

i should write some type of blogpost for this lol

spiral aurora
#

yea u should lol

#

traffic out the wazoo

haughty dust
#

i think it just needed it refresh a couple of times or the old sln was bust

#

better than when sdk is missing

spiral aurora
#

a PC restart probably woulda cut off some time

prime geyser
#

so now, it's time to actually fix the error

haughty dust
#

yess

#

now you're coding fr

prime geyser
spiral aurora
#

ah, nvm then

prime geyser
#

also windows is begging me to update

#

so it will probably update if i restart

spiral aurora
#

ever since i updated to 11 i dont get updates anymore

#

maybe once a month

prime geyser
haughty dust
#

oof

spiral aurora
#

hhd < ssd < nvme

prime geyser
#

ik

haughty dust
#

in 2024 pcs still use hdds

spiral aurora
#

white-noise machine

prime geyser
#

i have a 1 TB hhd

haughty dust
#

good for larger storage

#

longer term i should say

#

ssd no good for long term

spiral aurora
haughty dust
#

big boi

spiral aurora
#

ya, i have a pile of SSDs that have died over the years

#

BIG PILE

#

my HDD is my saving grace

haughty dust
#

they are more prone to digital degradation

prime geyser
#

the thing is, how did you use 2 TB

haughty dust
#

esp with frequent access

spiral aurora
#

😅

spiral aurora
#

im an asset junkie

prime geyser
#

also i have a 2 TB not a 1 TB hhd

spiral aurora
#

Audio files mostly

#

u can never have enough audio

prime geyser
#

some of my files are 100GB

haughty dust
#

my unity projects just keep stacking

spiral aurora
#

ya, ive been seeing alot of ppl have scenes larger than 100gb

#

thats insane to me

#

i cant even.. must be some big ole environments i guess

haughty dust
#

how does tarkov handle that? or is that not that big

#

not even sure what the biggest map in unity is thats hd

spiral aurora
#

cities skylines 😉

haughty dust
#

is it?

spiral aurora
#

iono.. but its a pretty big map.. but i think that game is scaled down

haughty dust
#

just feels like its just scaled down tiny

spiral aurora
#

yup

prime geyser
#

doing it in blender might save a lot of storage for that

spiral aurora
#

w/ a mod called 81 tiles.. u can use every single tile in the game..

#

i think default they lock u into 9 or so

prime geyser
spiral aurora
#

my 2080ti runs it fine

#

my 1060 did too.. but not as quickly

prime geyser
#

how

spiral aurora
#

idk.. they have some crazy optimizations in that game ¯_(ツ)_/¯

#

and they keep alot of it hush hush

prime geyser
#

my PC freezes up when I open discord

haughty dust
#

once I reach 1million population my shit starts dying

spiral aurora
#

ahah..

#

i dont have any games much over that

prime geyser
#

my PC is at 90% memory as we speak

spiral aurora
#

need a memory upgrade 👍

#

my CPU is my bottleneck

prime geyser
#

i have 16 gigs

haughty dust
#

same

prime geyser
#

but, my brother is the one who got this

#

he got a pre-built

spiral aurora
#

gotta do what u gotta do

prime geyser
#

i think we got a bit carried away xd

#

anyways, we have to fix the errors now

haughty dust
#

where is the error

#

the IDE now should tell you

prime geyser
#

i'm removing the comments now

#

this is what unity was telling me about

spiral aurora
#

yup

prime geyser
#

why does it give me an error tho

spiral aurora
#

hover over it

prime geyser
#

so what do we do

haughty dust
#

hover over the second error

spiral aurora
#

well u dont assign it like that

haughty dust
#

it tells you you cannot use access modifiers inside a method

prime geyser
spiral aurora
#
    public Transform play1;
    public Transform play2;
    public Transform play3;

    public Transform[] characters;```
haughty dust
#

the first three not needed btw, thats why i suggested array

spiral aurora
#
{
    charcters = new Transform[] {play1, play2, play2};
}```
#

like that i think

#

but yea.. u can just assign them in the inspector

#

no need to declare them seperately

#

player1 would be characters[0], player 2 would be characters[1], and soo on

haughty dust
#

yes just call it players[] avoid confusion

prime geyser
haughty dust
prime geyser
spiral aurora
#

is that what ur trying to do? like a list of players u can loop thru.. checking their distance.. and soo on

#

using a for loop would loop thru the collection of Transform[] characters

haughty dust
prime geyser
spiral aurora
#

wait i wanna see..

#

u dont need those 3 public gameobjects anymore..

haughty dust
#

you closed class early

prime geyser
haughty dust
#

because you initilized an array wrong , its reading the } from it as closing the entire class

#

messing up the rest

#

also the way its written in start is wrong because you never put access modifiers inside methods

spiral aurora
haughty dust
#

do this ^

spiral aurora
#

since they're gameobjects anyway

#

altho u coulld do it like this..

#

but thats weird

haughty dust
#

also if you wrote it as
public Transform player1; public Transform player2; public Transform player3;

Transform[] players = new Transform[3] { player1, player2, player3 };

it would've worked but no sense in doing that at all

#

but because they were Gameobjects it makes no sense, its trying to fit spheres inside a square hole

spiral aurora
#

hmm what happens when u leave the new [] blank?

prime geyser
spiral aurora
#

characters = new Transform[]

#

does it automatically figure out theres 3 elements?

haughty dust
spiral aurora
#

why no error?

#

hold on

haughty dust
#

since they are fixed

spiral aurora
#

im let loop it

haughty dust
haughty dust
spiral aurora
#

ya u hardcoded 3

#

mines blank.. but works the same

haughty dust
prime geyser
#

this doesn't give errors

   public Transform player1;
    public Transform player2;
    public Transform player3;
    [SerializeField] Transform[] players;

    void Awake()
    {
        Transform[] players = new Transform[3] { player1, player2, player3 };
    }
haughty dust
#

in the method yes it automatically knows mb

#

i got confused there

spiral aurora
haughty dust
#

all good my brain farted

spiral aurora
#

but yea.. i dont necessarily even have to drop in 3 elements.. the {x, y, z} thingy just makes it work

#

magic 🪄

spiral aurora
#

now u have players(0->2);

prime geyser
haughty dust
#

it will not affect the original array

#

remove awake entirely, and just assign in inspector

spiral aurora
#

ohh yea remove the Transform[] part of the awake/start

#

u just need to assign the players

#

players = new Transform..

haughty dust
#

^ and you dont need public Transform player1; public Transform player2; public Transform player3; anymore

#

array is literally a collection of players

spiral aurora
#

assign em via the inspector in other words

#

and dnt worry about setting them in code

#

(dynamic)

prime geyser
spiral aurora
#

b.c u didnt assign em in the inspector probably

haughty dust
#

you're prob still trying to new() an array with player1,2,3

spiral aurora
#

this is literally all you need

prime geyser
#

nice

spiral aurora
#

until u go to access them in code

haughty dust
#

put them back

#

click the player one and do Rename

#

then rename them all to player[0], player[1], player[2]

#

and do for all 3

#

then remove

#

only thing to keep in mind is collections/arrays are 0 index

prime geyser
#

wdym by do Rename

haughty dust
#

so player1 is player[0]

spiral aurora
#

lookie

#

ur looping thru this and it doesnt even exist now

prime geyser
haughty dust
#

that too

#

do you have places where you wrote player1 ,player2 et.?

#

like outside this script

prime geyser
haughty dust
#

did you save when you fixed the script from other issue of brackets

#

click save

prime geyser
#

this is my code rn (bc i'm getting kinda confused)

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

public class Enemies : MonoBehaviour
{
    public int enemy_health = 100;
    public string nearest_player = "Player1";
    private int random_number = Random.Range(0, 3);
    public Transform player1;
    public Transform player2;
    public Transform player3;
    [SerializeField] Transform[] players;

    void Awake()
    {
        players = new Transform[] { player1, player2, player3 };
    }

    void Start()
    {
        
    }

    void Update()
    {
        if (enemy_health <= 0)
        {
            Destroy(gameObject);
        }

        
    }

    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Bullet")
        {
            enemy_health -= 10;
        }
    }

    Transform GetNearestPlayer(Vector3 point)
    {
        Transform nearestPlayer = null;
        float minDistance = Mathf.Infinity;

        foreach (Transform player in players)
        {
            float distance = Vector3.Distance(point, player.position);
            if (distance < minDistance)
            {
                minDistance = distance;
                nearestPlayer = player;
            }
        }
        return nearestPlayer;
    }
}
haughty dust
prime geyser
haughty dust
#

right click it . n rename

#

but if you said you're not referencing it anywehre else dont worry then

#

delete them

spiral aurora
prime geyser
#

and remove the awake()?

spiral aurora
#

heres ur code... identical from when i copied from paste-bin

#

since they're empty

haughty dust
#

n save , you should hae no errors

#

if you do its another script

prime geyser
#

but this line is having errors because player1 and player2 and player3 don't exist

#

players = new Transform[] { player1, player2, player3 };

spiral aurora
#

really...

prime geyser
#

what do i replace player1, player2, and player3 with

haughty dust
#

lol wtf

#

bro remove the Awake method

prime geyser
haughty dust
#

and the player1,2,3

#

where does it say its missing

spiral aurora
prime geyser
#

do you want me to remove the players = new Transform[] { player1, player2, player3 }; line too?

prime geyser
spiral aurora
#

then player1 becomes players[0]

haughty dust
#

thats literally part of awake

#

how did you not remove that b4

spiral aurora
#

player2 becomes players[1]

#

player2 becomes players[2]

prime geyser
haughty dust
#

did you just delete Awwake () wuithout deleting the entire codelock

haughty dust
spiral aurora
#

thats a classic.. 🫣

haughty dust
#

you have to start doing a bit of c# crashcourse

#

learn what a method definition is etc

#

anatomy of a script

spiral aurora
#

this important

prime geyser
#

i was a just a bit confused on what you wanted me to do

#

but anyways, now there are no more errors

#

lemme test if that works

haughty dust
prime geyser
#

it works

prime geyser