Skip to content

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.

5 points

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?

2 points

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

2 points

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.

5 points

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

1 points

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

1 points

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:

  1. Delete the .sln file and the .csproj files from your project folder (they will get rebuilt when you reopen the project in Unity)
  2. Reinstall Visual Studio/Unity
1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.