I am trying to create a 2D Catch Game using the one from the tutorial as a guide, but I am having trouble with the script. In the HatController script (for controlling the hat player object) I changed hatWidth to ufoWidth but Visual Studio says: (local variable) float ufoWidth use of unassigned local variable "ufoWidth’
How do I assign it? I am new to programming and am trying to learn by making a game.
You assign to it with an assignment statement, e.g. “ufoWidth = 42;”.
Before you start mucking about with scripts, I think it’d be well worth your time to head on over to learncs.org, and work your way through the short course of tutorials there. That will give you a foundation in the basics, so you won’t trip over things like this.
Thanks for the heads up. Did a quick test and you’re right it wasn’t necessary. One of those habits I picked up because it complained enough times I felt it was always necessary and the one time I don’t verify it turns out not to be.