Try   HackMD

Use Godot First Time

tags: Godot

Extract some text, pictures as the note from Godot Engine documentation's Step by step.

Object-oriented design and composition

Node

All nodes have the following characteristics:

  • A name.
  • Editable properties.
  • They receive callbacks to update every frame. => Time related.
  • You can extend them with new properties and functions.
  • You can add them to another node as a child.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

For example, a CharacterBody2D node, a Sprite2D node, a Camera2D node, and a CollisionShape2D node.

The node can cover another node, according to the placed order.

Scene

Organizing nodes in a tree is called as constructing a scene. The Godot editor essentially is a scene editor. The engine only requires one as your application's main scene. This is the scene Godot will first load when you or a player runs the game.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Resource

Godot aggreagates the files as the resources and stores them in the filesystem, including: the pictures, scenes, scripts.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

GDScript

GDScript is an object-oriented and imperative programming language built for Godot. Key features:

  • Attach to node.
  • Tight editor integration, with code completion for nodes, signals, and more information from the scene it's attached to.
  • Built-in vector and transform types, making it efficient for heavy use of linear algebra, a must for games.
  • Supports multiple threads as efficiently as statically typed languages.
  • No garbage collection, as this feature eventually gets in the way when creating games. The engine counts references and manages the memory for you in most cases by default, but you can also control memory if you need to.
  • Gradual typing. Variables have dynamic types by default, but you also can use type hints for strong type checks.

_init()

The func keyword defines a new function named _init. This is a special name for our class's constructor. The engine calls _init() on every object or node upon creating it in memory, if you define this function.

_process(delta)

Godot will call the function every frame and pass it an argument named delta, the time elapsed since the last frame.

_unhandled_input()

  • _unhandled_input() is a built-in virtual function that Godot calls every time the player presses a key.
  • The Input singleton. A singleton is a globally accessible object. Godot provides access to several in scripts. It's the right tool to check for input every frame.

The InputMap is the most flexible way to handle a variety of inputs. You use this by creating named input actions, to which you can assign any number of input events, such as keypresses or mouse clicks. To see them, and to add your own, open Project -> Project Settings and select the InputMap tab. Click Show Built-in Actions:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Signal

Other nodes can connect to the node's signal and call a function when the event occurs.

Vector math

Yes! It is the Vector! Velocity is a kind of vector.