Since most of the red squiggly lines are under types, I’m assuming your missing Using Systems because anytime iv ever used Unity Engine there is always 1-2 USING states before Using Unity Engine.
I didn't mean he shouldn't start in game-dev, and I certainly wouldn't recommend starting with websites.
I just meant he should at least try to understand the basics. Game-dev is a great learning tool, and a great motivator to keep learning, but if you don't know some of the basic "why's" of programming, it's really easy to get frustrated if you get in super over your depth, because nothing ever works and you don't know why.
It's for a 2D sprite that needs to move left and right and up and down. When I hover over the error, it says System.Objects or System.Void is not defined or imported
I’m assuming that you don’t have experience and that’s why I’m advising because I think I have bit more than you in general, if you’re not complete beginner then sorry probably my advices won’t have any values since I’ve never developed in Unity
I’m just giving these suggestions from my intuition and gut feeling, not sure what they actually mean
No, I'm not that experienced and also just to let you know, we have a discord server for both new and existing game devs who can share ideas etc https://discord.gg/WBAZVa5
From what I can tell, all your code looks correct and shouldn't have any errors. The only thing you should change is that in C# classes are formatted as PascalCase, so your class should be named PlayerController and the file should have the exact same casing and spelling.
Based on your other comment about it not being able to detect System.Object, I would guess that something is messed up with your Unity install (since Unity comes bundled with it's own .NET libraries) or your solution/project files (.sln/.csproj). Try the following:
Delete the .sln file and the .csproj files from your project folder (they will get rebuilt when you reopen the project in Unity)
32 comments
Since most of the red squiggly lines are under types, I’m assuming your missing Using Systems because anytime iv ever used Unity Engine there is always 1-2 USING states before Using Unity Engine.
I accidentally deleted them. But I'll add them thx
No problem, Happy to help!
Change moveVelocity to rb.velocity?
Why
Cause youre not moving your rigidbody. Youre changing a random vector2 thats not linked to anything
Judging by the comments here and the errors in your code, you have little to no programming experience.
That's OK!
However, I'd recommend starting with some more basic stuff before jumping into Unity C# programming. /r/learnprogramming is a good resource.
If it were me, I'd explore these questions before trying to code up a game:
What is a class? Why would you use it? Why would you extend a class?
When I set a variable (such as your Vector2 moveVelocity), what is actually happening behind the scenes? Where is that data used?
Why do I need the "using" statements? What are they for?
No no, he should start right there where it’s interesting to him, he’ll get bored by building websites (or whatever)
You want to learn game dev, start in game dev
I didn't mean he shouldn't start in game-dev, and I certainly wouldn't recommend starting with websites.
I just meant he should at least try to understand the basics. Game-dev is a great learning tool, and a great motivator to keep learning, but if you don't know some of the basic "why's" of programming, it's really easy to get frustrated if you get in super over your depth, because nothing ever works and you don't know why.
make sure the name of the public class is the same as the name of the file (its caps Sensitive too)
It is
It's for a 2D sprite that needs to move left and right and up and down. When I hover over the error, it says System.Objects or System.Void is not defined or imported
I’m not used to whichever language you’re using but you should just import those classes
Import System or Include System or something like that
I written using System.Collections.Generic; and it still doesn't work
I did that and it still says System.Void
I’m assuming that you don’t have experience and that’s why I’m advising because I think I have bit more than you in general, if you’re not complete beginner then sorry probably my advices won’t have any values since I’ve never developed in Unity
I’m just giving these suggestions from my intuition and gut feeling, not sure what they actually mean
No, I'm not that experienced and also just to let you know, we have a discord server for both new and existing game devs who can share ideas etc https://discord.gg/WBAZVa5
The language is c# btw
It's my code?
For the future, you need to post console output errors.
From what I can tell, all your code looks correct and shouldn't have any errors. The only thing you should change is that in C# classes are formatted as PascalCase, so your class should be named PlayerController and the file should have the exact same casing and spelling.
Based on your other comment about it not being able to detect System.Object, I would guess that something is messed up with your Unity install (since Unity comes bundled with it's own .NET libraries) or your solution/project files (.sln/.csproj). Try the following: