151 Replies
Just call the method. Literally.
like, what do I type exactly?
This is one of the very first things you'd learn in C#
im looking through notes
i forgot
Google it
You'll need to put in some bare minimum effort before we help, honestly.
would it be I do smt like "Debug.Log(SayHelloThrice);"?1
try it
or am i thinking too much
$tias
ok
OH WAIT
From what you said so far... you know how to call a method
am i going in the right direction?
i can kinda see a problem
somewhat
that like the start() thing isnt able to reach the method outside of it
Uh, no
It is able to reach the method
Read the error message
oooh
cannot convert method group to object
Yep
so it CAN reach it, but its being used incorrectly
yes
Because
Debug.Log()
expects an object
to be passed to itah
And you're giving it the method itself
ok
So, two issues:
1. You're not actually calling your method still
2. Even if you were, that method is
void
, it does not return any sort of an objectoh
yeah mb
a method would be smt like "public class (method name)" right?
minus the ()
Uh, no
oh
public class Something
declares a class
Your method is definedtrue
You just need to... call it
Like you called the
Debug.Log
methodok, imma go through my notes rq
yeah so void methods are as it says, voided
right?
uhm, what would that mean exactly?
wait
A method being
void
means it doesn't return anythingok
so if i wanted this ti appear in the console, it wouldnt because its void
your
SayHelloThrice
method already calls Debug.Log inside it
you don't need to Debug.Log a Debug.Logoooh
(and Debug.Log is also a void method)
ok
so if i can use Debug.Log to call a method, but I cant in this scenario
no
Debug.Log is not related at all to calling methods
ok
other than in that it is itself a method
so im in the completely wrong area
ok
so i cant use debug.log, what should I use?
how about the method you made?
the one you want to call
do i just put in start() "SayHelloThrice"?
imma try it
nope
show us your attempt
so close
so very very close
MMMM
wait
Look at all the methods you've made and used so far
do i put void infront of it?
what do they all have in common?
no
or behind it
that would be a declaration
true
no, that would be invalid syntax
remember,
Debug.Log
is a void method
and you call it succesfully and correctly in your methodhmmmmmmmmmmm
im so close, yet im still missing a piece of the puzzle
hint: its round
or at least curved
PARENTHESIS
right?
$tias
I THINK IT WORK :D
🎉
no red squiggle :D
i feel accomplished, yet dumb
ok now I need to figure out how to make it say hello 3 times
in the console
for context
I used a for while in the method to i = 0;i<3:i++
no, you used a for loop
there is no while loop there
well yeah
a for loo[
loop
mb
i assume i would have to Debug.Log it so it appears in the console
or like Debug.Log("Hello");
my question goes to where inside the call would i put it
if i put it there at all
no
did you run the code you posted?
yes
nothing showed in console
Pobiega
REPL Result: Success
Console Output
Compile: 410.497ms | Execution: 45.703ms | React with ❌ to remove this embed.
(this is normal C#; not unity)
im using unity
I'm not. Deal with it.
😭
Unity will use
Debug.Log()
instead of Console.WriteLine()
ok
Console.WriteLine
is more or less identical to Debug.Log
yeahhm
so tell me, how would you modify the above code so that instead of 0 1 2, it printed hello hello hello?
switch statement?
what
O_O
how... what..
no
iforgot what it was
its in my memory somewhere
"What do I need to add to 1 to make 2?`
the square root of i^e8
😭
a switch statement is a control flow thing
true
it allows you to branch your code
hm
you need no branching here
you just need to replace the values 0 1 2 with "hello hello hello"
whats the code to do that?
no look
this is the code
yes
wait
do you understand WHY it prints 0 1 2?
do i literally just put (string "hello, hello, hello")
or just hello
with the string
"with the string"?
(string("hello"))
(string "hello") i mean
no
why would you even think that
where have you seen that syntax?
anyways
i would think it prints out it because of i
right.
and because teh code calls for it to be 0, 1, 2
not calss
what is it
anyways
... declares? increments?
yeah
one of those words
its a loop. it runs while i is less than 3
yes
and at the end of each iteration, it increments i
thats what that code does, indeed
so how do we modify this to instead of the current
i
value, print "hello"
?hm
don't overthink it
its much simpler than you assume
its hard for me :(
wait
is it smt like 0 = hello
no, we need
i
to be 0 1 and 2
to control how many times we printok
but there is no reason the body of the loop must use
i
hm
I'm not gonna spoonfeed you this one. Figure it out.
cant use string
overthinking it
go simpler
hm
you need to write a grand total of 7 characters.
including spaces?
wait
grand total
yeah
including everything
hint: how many characters is in the word hello?
5
so that leaves you with how many to spare?
2
mhm
(something here) = hello
nope, you're out of characters
shit
= hello
is 7"hello" ?
there you go
I want 25 minutes of my life back 🙂
so, again
how do we modify this?
i already tried switching out i for "hello", didnt work
crosses taht out
you sure?
Pobiega
REPL Result: Success
Console Output
Compile: 438.363ms | Execution: 64.400ms | React with ❌ to remove this embed.
works pretty well for me.
thats weird
it didnt work for me
Might I suggest you leave unity?
Its not really helping you at all
cant
school homework
its a really powerful game engine, but you're literally trying to take your very first steps in programming
its like giving a toddler a monstertruck before they can walk
tell that to my teacher
half the class dont know how to do shit
me included
thasts because you shouldn't start with unity, and either your teacher absolutely sucks at explaining the basics, or you were all sleeping
$helloworld
Written interactive course https://learn.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/tutorials/
Videos https://dotnet.microsoft.com/learn/videos
go through the interactive course here, and you'll learn the basics of C#
that will all apply to unity too
ok
how to decalre a method, how to call it, how to use variables, literals, etc
all that is covered
i think im just gonna turn this assignment in because its 15 minutes till its due
im gonna take a hit rq
thanks for the help you provided so far
ill learn it better eventually
enjoy the rest of your day
$close
Use the /close command to mark a forum thread as answered