❔ Use of unassigned local variable

EEmoEmu_6912/14/2022
I'm getting an error saying "Use of unassigned local variable "Input""

I just followed a tutorial on scripting a camera that follows your cursor, and it seemed to work fine for the dude in the video
Image
AAngius12/14/2022
That has no right to work
AAngius12/14/2022
Since you're using values of Input... to construct a new value for the Input
AAngius12/14/2022
You sure the local variable shouldn't be named input instead?
AAngius12/14/2022
And that Input isn't some property of MonoBehavior?
AAntonC12/14/2022
Input is a static class
AAngius12/14/2022
Close enough lol
EEmoEmu_6912/14/2022
gonna be honest, Idk what most of that meant
AAntonC12/14/2022
rename your local variable to input
EEmoEmu_6912/14/2022
ok
AAngius12/14/2022
And that's why I believe it's best to learn C# first, Unity second
EEmoEmu_6912/14/2022
I prolly would've gone that way if I were learning on my own, but it's for a class
EEmoEmu_6912/14/2022
I tried that and it just gave the same error but with the new name
AAngius12/14/2022
What's the error?
AAntonC12/14/2022
GetAxis should still be called on Input
AAngius12/14/2022
And what's the code now?
EEmoEmu_6912/14/2022
Use of unassigned local variable "Input"
AAntonC12/14/2022
you didn't save the file maybe
EEmoEmu_6912/14/2022
I haven't changed it since making the post
AAngius12/14/2022
uh
EEmoEmu_6912/14/2022
I tried saving it a lot
AAntonC12/14/2022
??
AAntonC12/14/2022
rename the variable?
AAngius12/14/2022
So you didn't fix the code... and the code isn't fixed
AAngius12/14/2022
Surprise, I guess..?
EEmoEmu_6912/14/2022
other than that, I meant
EEmoEmu_6912/14/2022
my bad
AAntonC12/14/2022
show it
EEmoEmu_6912/14/2022
ok
AAntonC12/14/2022
$code
MMODiX12/14/2022
To post C# code type the following:
```cs
// code here
```

Get an example by typing $codegif in chat

If your code is too long, post it to: https://paste.mod.gg/
AAngius12/14/2022
Did you do it in both places?
AAngius12/14/2022
Because you're creating the variable, and then you're returning it
EEmoEmu_6912/14/2022
this is after making the change to "Input" you suggested
AAngius12/14/2022
Rename just the variable
EEmoEmu_6912/14/2022
oh
EEmoEmu_6912/14/2022
I think I might be dumb
AAntonC12/14/2022
Input.GetAxis is a function access on a static class
AAngius12/14/2022
Image
AAngius12/14/2022
Green good change red bad change
EEmoEmu_6912/14/2022
ah gotcha
EEmoEmu_6912/14/2022
that fixed it, thanks guys!
AAntonC12/14/2022
also
AAntonC12/14/2022
$unity
MMODiX12/14/2022
AAngius12/14/2022
The Unity server people often send people to our server, when the issue has to do with the basic understanding of C# lol
EEmoEmu_6912/14/2022
ah thanks
AAccord12/16/2022
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.