0 votes

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():

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
        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

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
Godot version 3.4.2
in Engine by (12 points)

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 :)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.