GDScript error: The identifier "gravity_pull" isn't declared in the current scope.

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

Hello! Im new to godot and GDScript and im currently expiriencing an issue with getting my veriable “gravity_pull”. All the veriables are pulled from a diffrent script that i think is properly linked since every other pulled veriable is working.

here is the code of the movement:

    extends game_meneger

var velocity: = Vector2()


func _ready():
	pass

func _process(delta):
	velocity.y += gravity_pull * delta
	if	Input.is_action_pressed("move_right"):
		velocity.x = acceleration * speed
	elif Input.is_action_pressed("move_left"):
		velocity.x = -acceleration * speed
	else:
		velocity.x = 0
	if is_on_floor():
		if Input.is_action_pressed("jump"):
			velocity.y = -jump_strength
	velocity = move_and_slide(velocity, UP)

and here is the code of the GameMenager

extends KinematicBody2D
class_name game_meneger

#Gravity
var UP: = Vector2(0, -1)
export var gravity_pull: = float(30)
export var jump_strength: = float(300.0)
#movement behaviour
export var speed: = float(40)
export var max_speed: = float(80)
export var acceleration: = float(2)

The error that it gave me is “The identifier “gravity_pull” isn’t declared in the current scope.” on this line

velocity.y += gravity_pull * delta

You get error in this line because it is first line compiler reaches before crashing. Other variables would crash too. I am not sure about the nature of this error, but I can suspect export keyword sets default values after node is added to the tree, which is too late ? Did You make sure to save your class script manually in editor before running inherited node ? scripts are not automatically autosaved when running the project, let’s hope it is the only problem here :slight_smile:

Inces | 2022-02-19 15:07