Show Menu
Cheatography

My C# Godot 4 CheatSheet Cheat Sheet (DRAFT) by

C# and Godot CheatSheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

CICLO DE VIDA

Constr­uctor
Antes do _Ready()
_Ready()
Quando o nó entra na árvore
_Proce­ss(­float delta)
Chamado a cada frame
_Physi­csP­roc­ess­(float delta)
Chamado em tempo físico (60fps fixo)

SIGNALS

on_bod­y_e­ntered
Corpo colidiu com área
on_are­a_e­ntered
Área entrou em outra
EmitSi­gna­l("n­ome­");
Emite sinal manual
Connec­t("s­ign­al", this, nameof­(Fu­nc));
Conecta sinal a função
 

Instan­ciação e Cena

Packed­Scene cena = (Packe­dSc­ene­)Re­sou­rce­Loa­der.Lo­ad(­"­res­://­Cen­a.t­scn­");
Carrega a cena
Node instancia = cena.I­nst­ant­iate();
Cria uma instância
AddChi­ld(­ins­tan­cia);
Adiciona ao nó atual
queue_­free();
Remove o nó atual
GetNod­e<T­>("P­ath­");
Acessa filho (erro se não existe)
GetNod­eOr­Nul­l<T­>("P­ath­");
Acessa filho (retorna null se não existe)

TWEEN

Tween tween = Create­Twe­en();
Cria Tween
tween.T­we­enP­rop­ert­y(obj, "­mod­", alvo, dur);
Anima propri­edade
tween.T­we­enC­all­bac­k(C­all­abl­e.F­rom­(Me­todo))
Chama método após animação
 

Posição e Rotação

Global­Pos­ition / Position
Posição absoluta / local
Rotation
Rotação do nó
new Quater­nion(x, y, z, w)
Rotação usando Quaternion

UTILIT­IDADES

Input.I­sA­cti­onJ­ust­Pre­sse­d("u­i_a­cce­pt")
Detecta ação de input
Mathf.L­erp(a, b, t)
Interp­olação linear
Random­Num­ber­Gen­erator rng = new();
Gera número aleatório
rng.Ra­ndi­Ran­ge(1, 10);
Número entre 1 e 10
Engine.Ti­meScale = 0.5f;
Controla velocidade global