#Help

1 messages ยท Page 1 of 1 (latest)

vivid jacinth
#

Whatโ€™s ur issue

cyan solstice
#

when i got to hit play to text if my new code works it just flickers off

cyan solstice
#

idk how to explain that's why i asked if i could call to screen share

cyan solstice
#

sorry its on my phone

#

see what i meant by flickers

#

im very new to unity

vivid jacinth
cyan solstice
#

ya

vivid jacinth
#

so when u press play unity just flickers like 4 times?

cyan solstice
#

one time

#

Also every time I restart this comes up

#

this error: The associated script cannot be loaded, please fix any compile errors and assign a valid script

vivid jacinth
#

did u fix the errors in ur script?

cyan solstice
#

I canโ€™t find any

#

Iโ€™ve been following a video exactly

#

using UnityEngine;

public class Sanke : MonoBehaviour
{
private Vector2 _direction = Vector2.right;

private void Update()
{
if (Input.GetKeyDown(KeyCode.W)){
_direction = Vector2.up;
}else if (Input.GetKeyDown(KeyCode.S)){
_direction = Vector2.down;
}else if (Input.GetKeyDown(KeyCode.A)){
_direction = Vector2.left;
}else if (Input.GetKeyDown(KeyCode.D)) {
_direction = Vector2.right;
}
}
private void FixedUpdate()
{
this.transForm.position = new Vector3(
Mathf.Round(this.transForm.position.x) + _direction.x,
Mathf.Round(this.transForm.position.y) + _direction.y,
0.0f
);
}
}

#

(that's the code)

torpid crystal
#

sanke != Sanke

vivid jacinth
#

it should give u an error in ur console

#

did u configure ur ide?

cyan solstice
vivid jacinth
#

did u configure ur ide?

cyan solstice
vivid jacinth
#

and r u using visual studi code or visual studio

cyan solstice
#

vsc

#

how do i know if i configured the ide

#

sorry ๐Ÿ˜… like i said very new to coding

torpid crystal
#

configuring it is like autocorrect for code and helps you identify problems

cyan solstice
#

ok give me a sec

vivid jacinth
#

it is so much better

#

vsc is just a text editor

#

pretty much

#

visual studio is an ide

#

and is way better for unity

#

and to configure it you go into project setting you go to external tools and chose visual studio as the editor

cyan solstice
#

One sex

#

Lmao sec

vivid jacinth
#

๐Ÿคฆโ€โ™‚๏ธ

cyan solstice
#

How might I get to project settings

vivid jacinth
#

its either that or preferences

#

there will be something called external tools

#

donwlaod visual studio adn use visual studio

cyan solstice
#

Ok I did that

vivid jacinth
#

please download visual studio

#

it will make ur life so much better

#

trust me @cyan solstice

#

its so much better

cyan solstice
#

Can we first try to get it to work with vsc then I can use the other

vivid jacinth
#

close it and open it

#

im not sure if it has intellisense tho

#

i havent used it for this

#

that much

cyan solstice
#

Ok Iโ€™ve reopened it

vivid jacinth
#

so

#

when you type UnityEngine.

#

does anything pop up?

cyan solstice
#

Sorry one second just trying something

vivid jacinth
#

alr

cyan solstice
vivid jacinth
#

yay

vivid jacinth
#

i need to see something about visual studio

cyan solstice
vivid jacinth
#

good good

cyan solstice
#

there you go

vivid jacinth
#

well ur all set

#

but i very much reccomend u use visual studio

#

but whatever floats ur boat

cyan solstice
#

how might i fix the problems tho

vivid jacinth
#

unityengine is all of the errors

cyan solstice
#

like that the top

vivid jacinth
#

not at the top

#

then all ur errors will go awau

cyan solstice
#

ok

#

This is still there

vivid jacinth
cyan solstice
#

Ya

vivid jacinth
#

remove it from the gameobkect

#

then put it back on

cyan solstice
#

Where is gameobkect

vivid jacinth
#

the gameobject the script is attached to

#

becasue it cant load the scropt there isnt an active instance

#

so you need to remove the instance of the script

#

then reattach it

#

there arent any errors in the code so it should be all good

#

it compiles, you run the game, then we are all happy.

cyan solstice
#

where do i remove im sorry a bit lost

#

Like in the left

vivid jacinth
#

int eh right

#

where is says script

#

inteh component area

#

press the 3 dots

#

and press remove componenet

#

then after u do that drag the script back ontp the thing u had it attached to before

#

and then ur code should run...

cyan solstice
#

Why๐Ÿ˜ญ

vivid jacinth
#

open up the script

#

the name of ur script

#

and the class are different

#

show me the script

cyan solstice
#

One sec I might have fixed

#

there's my script

vivid jacinth
#

the name of ur script

#

make that a lowercase s

cyan solstice
#

line 3?

vivid jacinth
#

line 3

#

save it

#

then attach ur script

#

ur class name has to be the same as ur script name

cyan solstice
#

still don't work

vivid jacinth
#

show me the script

cyan solstice
vivid jacinth
#

u have two scripts

#

named the same thing

cyan solstice
#

I donโ€™t think so

vivid jacinth
#

go into ur assets folder

#

look through everything

#

check teh scripts

cyan solstice
#

?

#

thats all i have

vivid jacinth
#

thats in ur scenes folder

#

do u have anything in ur assets folder?

cyan solstice
#

just the folder called scense

#

thats what you mean right

#

Still there

vivid jacinth
#

hm...

#

try and restart unity

#

save nad restart

cyan solstice
#

Restart what unity?

vivid jacinth
#

restart the app

#

sane i and close and open it

cyan solstice
#

Ok one sec unity takes a sec to reopen

vivid jacinth
#

alr

cyan solstice
#

Alright itโ€™s reopened

vivid jacinth
#

try and attach the script again

cyan solstice
#

Still no

vivid jacinth
#

you may have to instlal visual studio

#

becuase you mayneed the NET SDK

cyan solstice
#

Ok Iโ€™ll do that

vivid jacinth
#

wait a second

#

let me consult with my superiors

cyan solstice
#

Ok

remote fox
#

looks around

#

stinks in here.

#

๐Ÿ˜›

#

gimme a bit to catch up

vivid jacinth
#

Uthel is my boss

#

They can help us out

remote fox
#

ye easy

#

sanke != Sanke

vivid jacinth
#

i checked the class name

cyan solstice
#

Sorry guys I appreciate the help

vivid jacinth
#

the class name and script name are the same

#

no errors in the code

#

no other scripts besides this one

#

and the script wasnt previosly on the player when trying to reattach it

remote fox
#

oh wait you already caught the caps

vivid jacinth
#

I also helped them configure their ide to check fo erros

vivid jacinth
remote fox
#

still the prob ๐Ÿ™‚

vivid jacinth
vivid jacinth
#

they are the same

#

the script name

remote fox
vivid jacinth
#

and the class name

#

they are both lowercase

remote fox
#

look at screenshot right below 'still didn't work'

cyan solstice
vivid jacinth
#

i dont see it

remote fox
vivid jacinth
#

u spelled it correctly in the class

#

but not on the script

remote fox
#

๐Ÿ‘

#

gl!

vivid jacinth
#

u have to either make both of them

cyan solstice
#

Iโ€™m pretty sure I fix the spelling mistake

vivid jacinth
#

sanke

#

or both of the snake

#

the class name and the script name

cyan solstice
#

Here look

#

see

#

@remote fox

#

@vivid jacinth is this still wrong

vivid jacinth
#

I SEE THE PROBLEM

#

HAHAHAHA

#

U HAVE AN ISNTANCE OF THE SCRIPT ATTACHED

#

ITS A BROKEN INSTANCE

#

BUT AN INSTANCE NONETHELESS

remote fox
#

lol calm down

vivid jacinth
#

HAHAHAHAHAHAHA

vivid jacinth
#

lmao

#

xD

#

remove where it says script 1

#

press the three dots

#

remove component

remote fox
#

remove that component*

#

ye

vivid jacinth
#

then drag ur snake script back onto it

cyan solstice
vivid jacinth
#

oh...

cyan solstice
#

still nope

vivid jacinth
#

๐Ÿ˜ญ

#

@remote fox have fun

cyan solstice
#

๐Ÿ˜ญ

vivid jacinth
#

i need to finish some spanish hw rlquk

remote fox
#

the problem now is still the same as before, you have compilation errors in that script

torpid crystal
# cyan solstice

Copy the code here, delete the old script. And make a new one. Then paste it in

cyan solstice
remote fox
#

... k ill go read back further

#

im late to the convo ๐Ÿ˜›

cyan solstice
#

using UnityEngine;

public class snake : MonoBehaviour
{
private Vector2 _direction = Vector2.right;

private void Update()
{
if (Input.GetKeyDown(KeyCode.W)){
_direction = Vector2.up;
}else if (Input.GetKeyDown(KeyCode.S)){
_direction = Vector2.down;
}else if (Input.GetKeyDown(KeyCode.A)){
_direction = Vector2.left;
}else if (Input.GetKeyDown(KeyCode.D)) {
_direction = Vector2.right;
}
}
private void FixedUpdate()
{
this.transForm.position = new Vector3(
Mathf.Round(this.transForm.position.x) + _direction.x,
Mathf.Round(this.transForm.position.y) + _direction.y,
0.0f
);
}

}

remote fox
#
to do stuff like this;
vivid jacinth
# remote fox

oml i never knew u could do csharp. i normally just do cs

remote fox
cyan solstice
remote fox
#

I'm seeing tons of compilation error, that script is an absolute mess

#

you need to configure your ide

#

and fix all the problems

#

and its not even the whole thing!

vivid jacinth
cyan solstice
remote fox
vivid jacinth
remote fox
#

this.transForm

#

this.transForm

vivid jacinth
remote fox
#

kihjgfsjkhdfks

vivid jacinth
#

oml

#

well i went through the process

#

we made it visual studio code in the external tools

#

and refreshed it

remote fox
#

it was unsuccessful ๐Ÿ˜›

vivid jacinth
#

it said assembly c# tho

#

thats weird

cyan solstice
vivid jacinth
#

thats why i always tell everyone... visual studio

#

visual studio

remote fox
#

private Vector2 _direction

vivid jacinth
#

still wont compile

remote fox
#

oh no wait thats fine

vivid jacinth
torpid crystal
vivid jacinth
cyan solstice
#

Uthel ok can you run me through how to config it then

#

that like vsc

remote fox
#

I think I was mistaken, it looks like its set up right

#

you just.. didn't do anything about the stuff underlined in red

#

those are errors, unity won't even look at the script if it won't compile

#

if anything is underlined in red, not only will the script not work, big red flashing lights and confusing messages will pop up calling you dumb

cyan solstice
#

i'm really new to this so are the errors easy to fix

vivid jacinth
# cyan solstice Here look

look here @remote fox this is why i am confused. it is configured. yet there arent any errors showing up

#

even though there are visibly many

cyan solstice
#

they only showed up when i typed this.transForm

remote fox
#

now there are ๐Ÿ˜›

#

I think in this case you can just remove the bottom two lines of the script. that one extra {, and the this.transform line

#

lemme count the braces real quick

#

oof I mean real slow

#

holy man they all over the place

#

yeah one extra one you don't need at the bottom

vivid jacinth
#

please i beg @cyan solstice use visual studio

#

we would not be having any of these errors

remote fox
#

... sure you would

#

ide would not change this

vivid jacinth
#

like showing up

#

when i attached that pic to u

#

the errors didnt show up

#

they would have in visual studio

remote fox
#

I think here, perhaps it was a bug from initially configuring it

#

did you make him reboot? ๐Ÿ˜›

vivid jacinth
#

yeah

remote fox
#

shrug, welp, it's workin now ๐Ÿ™‚

vivid jacinth
#

lol

#

either way i just like visual studio more

#

it feels nicer

#

idk how to explain it

remote fox
#

ive only ever used vscode so I dunno.

vivid jacinth
#

and it literall feels like sublime

#

but a little ide ish

cyan solstice
#

more errors noe

#

now

remote fox
#

good! I like errors

cyan solstice
remote fox
#

transForm is incorrect

vivid jacinth
remote fox
#

no caps on the F

vivid jacinth
#

that should be it

cyan solstice
#

omg it worked!!!!!!!!!

remote fox
#

great ๐Ÿ™‚

cyan solstice
#

@remote fox @vivid jacinth thanks so much

#

im sorry i took up so much of your time @vivid jacinth ๐Ÿ˜…

#

ya i was following this vid

#

so why did Cap F work in transForm for him @remote fox

remote fox
cyan solstice
#

lmao

#

ok well thanks again

vivid jacinth
#

any way that i can help i will do it ๐Ÿ‘

#

have a nice day and good luck on ur game

cyan solstice
#

thanks