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:
https://youtu.be/y2HBgjNxS4s?list=PLv3l-oZCXaql20IlPe7gfBEzomnPSLekY&t=519
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