❔ Use of unassigned local variable
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
37 Replies
That has no right to work
Since you're using values of
Input
... to construct a new value for the Input
You sure the local variable shouldn't be named input
instead?
And that Input
isn't some property of MonoBehavior
?Input
is a static classClose enough lol
gonna be honest, Idk what most of that meant
rename your local variable to
input
ok
And that's why I believe it's best to learn C# first, Unity second
I prolly would've gone that way if I were learning on my own, but it's for a class
I tried that and it just gave the same error but with the new name
What's the error?
GetAxis should still be called on Input
And what's the code now?
Use of unassigned local variable "Input"
you didn't save the file maybe
I haven't changed it since making the post
uh
I tried saving it a lot
??
rename the variable?
So you didn't fix the code... and the code isn't fixed
Surprise, I guess..?
other than that, I meant
my bad
show it
ok
$code
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/Did you do it in both places?
Because you're creating the variable, and then you're returning it
BlazeBin - tgjkcvlbxgva
A tool for sharing your source code with the world!
this is after making the change to "Input" you suggested
Rename just the variable
oh
I think I might be dumb
Input.GetAxis is a function access on a static class
Green good change red bad change
ah gotcha
that fixed it, thanks guys!
also
$unity
The Unity server people often send people to our server, when the issue has to do with the basic understanding of C# lol
ah thanks
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.