–2 votes

Hi! I have a trouble with autocomplete. I'm using Apple MacBook Air M1 2020 and Godot Engine v3.4.4.stable.official.419e713a2

First example:

extends MovementState
class_name GroundMovement

export(float) var _magnitude := 5.0

onready var _controls: PlayerControls = $"../../Controls" as PlayerControls

var _input_movement := Vector3.ZERO
var _movement := Vector3.ZERO

func should_enter() -> bool:
    return true # _body.is_on_floor()

func should_exit() -> bool:
    return false # !_body.is_on_floor()

func enter() -> void:
    print("Entered Ground state!")

func exit() -> void:
    print("Exited Ground state!")

func process_movement(delta: float) -> void:
    # _input_movement = _controls. - no autocomplete
    _input_movement = _controls.get_movement()
    _movement = _input_movement * _magnitude

    _body.move_and_slide(_movement, Vector3.UP, true)

Inside processmovement, when i type _inputmovement = _controls. I get no autocomplete!

Here is PlayerControls source:

extends Node
class_name PlayerControls

var _movement := Vector3.ZERO

func get_movement() -> Vector3:
    _movement = Vector3.ZERO

    if Input.is_action_pressed("move_forward"):
        _movement.z += 1.0

    if Input.is_action_pressed("move_backward"):
        _movement.z += -1.0

    if Input.is_action_pressed("move_right"):
        _movement.x += 1.0

    if Input.is_action_pressed("move_left"):
        _movement.x -= 1.0

    return _movement.normalized()

Second example: I have a class that is supposed to be a movement state machine. Here is the code:

extends Node
class_name MovementStateMachine

var _current_state: MovementState = null

var _states := []

func _ready() -> void:
    for child in get_children():
        if child is MovementState:
            var new_state := child as MovementState
            _states.append(new_state)
            print("Registered state %s" % new_state.name)

    _current_state = _get_new_state()

    if _current_state == null:
        push_error("Failed to get initial MovementState!")
        get_tree().quit()


func _get_new_state() -> MovementState:
    var current_state: MovementState = null

    for state in _states:
        current_state = state as MovementState
        # if current_state. - no autocomplete
        if current_state.should_enter():
            return current_state

    return null

func _process(delta: float) -> void:
    # _current_state. - no autocomplete
    _current_state.process_movement(delta)

I'm using static typing and class_name, but autocomplete still doesn't work! I will realy appreciate your help.

Godot version Godot Engine v3.4.4.stable.official.419e713a2
in Engine by (10 points)

Maybe it's a bug. Have you tried putting in code like this?

var _input_movement: Vector3 = Vector3.ZERO
var _movement: Vector3 = Vector3.ZERO

2 Answers

–2 votes

Suddenly today it started working. I've also tried rest`rting the editor several times yesterday.

by (10 points)
+3 votes

Autocomplete of references to hard paths within one scene will not work, when different scene Tab is active in editor.

by (5,557 points)
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 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 webmaster@godotengine.org with your username.