Flappy Bird Game Parser Error: Identifier not found "Bird"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By NoobishDev

Hi I get the message “Parser Error: Identifier not found: bird” for my project which prevents the game from running. I have used the identifier bird in other places and it works perfectly but for some reason it is not being recognized when I used it to create the flap(): function which is located inside of the #FlappingState. I troubleshooted for hours but I can’t figure out what I did wrong.

I am using version v2.15.stable official (The tutorial I am following is not compatible to 3.0). Here is the link to the tutorial I am following with the timestamp:

Thanks for your help!

# birdscript
extends RigidBody2D

onready var state = FlappingState.new(self)

func _ready():
	set_process_input(true)
	set_fixed_process(true)
	pass
	
func _fixed_process(delta):
	state.update(delta)
	pass
	

	
func _Input(event):
	state.Input(event) 
	pass
	
# Flying State -----------------------------------------------------------------------------------------
class FlyingState:


func _init():
	pass

func update(delta):
	pass

func input(event):
	pass 


func exit():
	pass

# Flapping State -----------------------------------------------------------------------------------------
class FlappingState:
	var bird

func _init(bird):
	self.bird = bird 
	
	
	bird.set_linear_velocity(Vector2(50, bird.get_linear_velocity().y))
	pass

func update(delta):
	if rad2deg(bird.get_rot()) > 30:
		bird.set_rot(deg2rad(30))
	bird.set_angular_velocity(0)
	
	if bird.get_linear_velocity().y > 0:
		bird.set_angular_velocity(1.5)
	pass

func input(event):
	if event.is_action_pressed("flap"):
		flap()
		pass 
		
		
func flap():
	bird.set_linear_velocity(Vector2(bird.get_linear_velocity().x, -150))
	bird.set_angular_velocity(-3)
	pass
	
func exit():
		pass
	

# HitState State -----------------------------------------------------------------------------------------
class HitState:


func _init():
	pass

func update(delta):
	pass

func input(event):
	pass 


func exit():
	pass

# Ground State -----------------------------------------------------------------------------------------
class GroundState:


func _init():
	pass

func update(delta):
	pass

func input(event):
	pass 


func exit():
	pass

You didn’t say on what line you’re getting the error.

kidscancode | 2019-02-24 03:22

The errors were on line 64-67.The indentation got rid of the error and the scene now runs. (Thank you for that. solution). However the bird does not flap like it did before I reformatted the code. My code looked like this before it was reformatted and it worked perfectly it looked just like this:
https://youtu.be/y2HBgjNxS4s?list=PLv3l-oZCXaql20IlPe7gfBEzomnPSLekY&t=266

Here is my new code. There is no error messages it is simply not allowing me to control the bird like I was able to before. Instead the bird just falls to the ground.

# birdscript
extends RigidBody2D

onready var state = FlappingState.new(self)

func _ready():
	set_process_input(true)
	set_fixed_process(true)
	pass
	
func _fixed_process(delta):
	state.update(delta)
	pass
	

	
func _Input(event):
	state.Input(event) 
	pass
	
	# Flying State -----------------------------------------------------------------------------------------
class FlyingState:
	
	
	func _init():
		pass
	
	func update(delta):
		pass
	
	func input(event):
		pass 
	
	
	func exit():
		pass
	
# Flapping State -----------------------------------------------------------------------------------------
class FlappingState:
	var bird
	
	func _init(bird):
		self.bird = bird 
		
		
		bird.set_linear_velocity(Vector2(50, bird.get_linear_velocity().y))
		pass
	
	func update(delta):
		if rad2deg(bird.get_rot()) > 30:
			bird.set_rot(deg2rad(30))
		bird.set_angular_velocity(0)
		
		if bird.get_linear_velocity().y > 0:
			bird.set_angular_velocity(1.5)
		pass
	
	func input(event):
		if event.is_action_pressed("flap"):
			flap()
		pass 
		
		
	func flap():
		bird.set_linear_velocity(Vector2(bird.get_linear_velocity().x, -150))
		bird.set_angular_velocity(-3)
		pass
	
	func exit():
		pass
	
# HitState State -----------------------------------------------------------------------------------------
class HitState:
	
	
	func _init():
		pass
	
	func update(delta):
		pass
	
	func input(event):
		pass 
	
	
	func exit():
		pass
	
# Ground State -----------------------------------------------------------------------------------------
class GroundState:
	
	
	func _init():
		pass
	
	func update(delta):
		pass
	
	func input(event):
		pass 
	
	
	func exit():
		pass
	

NoobishDev | 2019-02-24 14:45

Try renaming the main class function _Input to _input. I’m pretty sure function names are case-sensitive.

SIsilicon | 2019-02-24 15:41

Thank you so much SIsilicon! That worked. I must have done that trying to “fix” something else. Have a great day!

NoobishDev | 2019-02-24 15:57

Glad I could help. I converted my comment to an answer.

SIsilicon | 2019-02-24 18:51

:bust_in_silhouette: Reply From: SIsilicon

I noticed that your inner classes’ functions don’t have indentation. The parser probably mistook their functions for the main class’s own, which indeed doesn’t have bird defined.