gdo Flashcards
A Prefab in unity is called a
Scene in godot
The usual components of a player are
Animated Sprite, body, collider
res:// refers to
the base directory of the project
To get a component in a script, instead of using get_node you can also use
$NodeName
To create a scene
right click on the node and choose save node as scene
The root node is essentially a
viewport
Note: To change the viewports values go to
project -> project settings -> display -> window
To add resources to your file system
right click in file system -> show in file manager
and drag the resources into that folder that pops up
A sprite node automatically inherits all the
functionality of a Node2D
To give a sprite an image you must drag the image
into its texture field
Note: An image with multiple images together that form an animation uses the “Atlas Texture”
Note: If you want an animation, this needs to be an animated sprite
In godot the pivot point field is called the
offset
To add a new script to a node
right click -> attach script
To get the x and y lengths of the viewport, type
get_viewport().size.x
get_viewport.seize.y
To change the main scene (scene that renders when you press play)
Project -> Project Settings -> Application -> Run -> Main Scene
To set the position of using a vector, type
Vector2(x, y)
To rotate a node from a script, type
rotate(deg2rad(90))
The value of multiplying speeds by delta in the _process function is
that it will normalize the speed across different machines
To translate a node from the script, type
translate(Vector2(x, y))
To add a node to a node from a script, type
add_child()
To create an animated sprite
Add AnimatedSprite node
Set frames field to sprite frames
Add images to the sprite frames
Set animation field to the same name of the animation you used in the sprite frames
To get the mouse position, type
get_viewpost().get_mouse_position()
To run code if a click is happening, type
func _process(delta): if Input.is_mouse_button_pressed(BUTTON_LEFT): pass
To set and check the type of a node, type
my_node.set_meta(‘type’, ‘wall’)
my_node.get_meta(‘type’)
To access a variable from a different script, type
get_node(“../nodePath”).variable
To make a kinematicbody2d chase, type
const SPEED = 500
func _process(delta): var vec = target_position - self.position # getting the vector from self to the mouse move_and_collide(vec.normalized() * delta * speed)