reading documentation

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

Its a bid embarrising and almost to afraid to ask. I got trouble reading the documentation.

What is my problem. Is see all these functions I think I can use but when trying them it gives an error. Looking at the documentation it seem simple. So I’m missing some point.

For example InputEventKey — Godot Engine (3.0) documentation in English

I see that I should be able to use:

if InputKeyEvent:
    do something

Then this does not work as expected I look up Member variables

bool echo - If true the key was already pressed before this event. It means the user is holding the key down.
bool pressed - If true the key’s state is pressed. If false the key’s state is released.

So I think I can enter

InputKeyEvent.echo or something else. But all keep returning errors.

Can somebody explain me how I should read this. InputKeyEvent is just example what is puzzling me.

Aha I do understand that InputKeyEvent you need to use in the func _input

But how can you know from the docs?

:bust_in_silhouette: Reply From: rolfpancake

It is always recommended to read the step-by-step guide and the tutorials first. You are trying to use a class instead of an instance of a class.

An input-event is registered in one of the _input()-functions. This function provides some arguments which are basically instances you can use in the codeblock below. So you should write:

func _input(event):
    if event is InputKeyEvent:
       #  do something...

Further reading:

It is absolutly great to use the class reference to learn something new. But keep in mind that it is a reference which needs fundamental knowledge of how the systems in Godot are entangled together. You really should read at least the step-by-step guide and if you don’t like the tutorials I can recommend to dive into the provided demos to learn how code is structured.