All examples in this repo runs in Godot v3.5.3.
This project contains a series of experiments, scripts and studies I've made in Godot through all this years.
Every DemoScene implements one mechanic I've created, or a mechanic existing in another game that I tried to replicate.
I hope you can use my scripts as an example or as a base for your studies in this amazing engine 😃
Enjoy! 👾
- No scripts required, you can make parallax effects in Godot only using the
ParallaxBackground
andParallaxLayer
nodes
- It's simple to make a Node always "look" at the mouse position, just use the
look_at()
function
func _process(delta):
look_at(get_global_mouse_position())
- To create a tileset, create your Nodes in a separate scene, and convert the
whole scene in menu
Scene -> Convert To -> TileSet
- To use a tilemap to create your levels, add a
Tilemap
Node in your scene, and load the tileset created in last step
- This is the most simple and basic 2D platform player you can have. He can walk, he can jump, and have Idle, walking, and jumping animations. You can check the code here
- In this example, I tried to simulate a slow motion effect, just changing
gradativally the
time_scale
value of the engine. You can check the code here
- This example implements a 3D arcade race car mechanic. This technique uses a sphere to run all the physics, and visually replace the sphere for the car 3D model
- This technique I've learned from this amazing tutorial
- In this new character script, gravity is not a fixed value randomly chosen by
you. Instead, you set the blocks
UNIT_SIZE
of your tilemap, and all values will be calculated according to your blocks - This way, it's easier to control how high (in blocks) and how much distance (in blocks) your character can reach in a jump
- Holding the "jump" button will make your character jump higher
- This player also had a
Tween
node to make some cool animations when you're jumping and when you're landing. You can configure how much the character will "deform" changing the "squash" value. - And here's the code
- A simple and smooth boomerang
- Go towards mouse click coordinates
- Always return to the player
- Code here
Tips and tricks
- To get the direction (
Vector2
) between 2 positions (Vector2
)
var direction = (target - start_position).normalized()
- To move your object towards this direction
position += direction.rotated(rotation) * speed * delta
- To calc the distance between 2 positions
var distance_to_target = position.distance_to(target)
- In this demo, I tried to reproduce the "3 steps jump animation" used in The Messenger
- This jump uses 3 animations, one when the character is upping, one when he's on top, and another when he's falling.
- I made this script to obtain this result
func animate():
if !is_on_floor():
if abs(motion.y) > JUMP / 2:
if motion.y < 0:
animator.play("Jump_up")
else:
animator.play("Jump_down")
else:
animator.play("Jump_roll")
- With this simple script you can control a rolling ball through a 2D scenario
- You can roll to the left, right, and you can jump
- This is a simple example of a shader covering the whole screen
- How I make:
- Add a
TextureRect
node - Add a simple
white image
as a texture to your
TextureRect
node - Check the
expand
option - Adjust the
rect
size to fill your whole window (you can check your window size inProject → Project settings → Window
) - In
Material
section, add aShaderMaterial
- Load your shader
- Add a
- For this example, I used this screen glitch shader
- You can find some amazing shaders ready to use in your game in Godot Shaders website, or in Shadertoy (but shaders from Shadertoy need to be converted)
- In this example, I tried to reproduce the Olija spear effect
- You can throw your spear in any direction using the
Mouse Left
- The spear sticks to any physic body it hits
- If you press
R
, you pick you spear back - If you press
Mouse Right
, your character teleports to spear position - You can check how I made this effect here
- A 2D raycast weapon, with some nice bullet trail, animation hit, and cartridge ejection effects
- Shoots in mouse direction
- Automatic and semi automatic modes
- Emit signals when it shoot, reload, hit, etc
- Shoot, reload, and empty bullets sounds
- Adjustable
damage
,spread rate
,recoil time
,bullets
andreload time
- Script here