Error after putting in second person view code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GhostBall338
:warning: Old Version Published before Godot 3 was released.

Hi! I’m having a error pop up after i enter in my code to see second person. here is my code (Thank you Zylann!): func _process(delta):

vertical

if Input.is_key_pressed(KEY_W): # do action here
elif Input.is_key_pressed(KEY_S): # do action here

horizontal

if Input.is_key_pressed(KEY_A): # do action here
elif Input.is_key_pressed(KEY_D): # do action here

If you can see the problem, than please tell me what it is, and how i can fix it! Or if you have a different code, that will allow me to see see second person, than please tell me, because i will try it! ( it said the error was: error (14, 1): Expected idented block after if, so plz tell me what that means if you know!

enter a pass after every if(in their block instead of the comment) until you fill it out, you have blocks of code with no proper code in them right now, by adding the pass method it will solve the error and you can always remove it and put a different code in there(proper one)

rustyStriker | 2017-11-16 17:18

You should edit the question and mark you code as a code sample so we can see it better. You can do that by selecting the code and pressing Ctrl+K or by pressing the curly braces button.

bitbloom | 2017-11-16 17:32

:bust_in_silhouette: Reply From: bitbloom

Whenever an error has a tuple, it’s showing you where the error is. In your case, you have (14, 1) which means the 14th line, 1st character. So you should check there. The description part of your error message Expected idented block after if means that you didn’t indent after an if statement. In GDScript and Python (which GDScript is based on) there are no code block braces, instead you must indent with whitespace.

Typical programming language:

if (condition) {
    print(result)
}

Python / GDScript:

if (condition):
    print(result)

Notice the colon and indentation? Whereas in a typical programming language indentation is optional, in Python and GDScript it is required. You can easily create indentation with the Tab ↹ key. The editor in Godot with mark tab characters with a double right arrow quote (»).

That being said, there seem to be other errors in your code. Here is how your intended code should look.

func _process(delta):
	## Vertical
	if(Input.is_key_pressed(KEY_W)):
		pass
	elif(Input.is_key_pressed(KEY_S)):
		pass
	
	## Horizontal
	if(Input.is_key_pressed(KEY_A)):
		pass
	elif(Input.is_key_pressed(KEY_D)):
		pass