Your First 2D GAME From Zero in Godot 4 **Vampire Survivor Style**

4 min read 17 hours ago
Published on Nov 21, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial will guide you through creating your first 2D game using Godot 4, inspired by roguelite shoot-'em-ups like Vampire Survivor. You'll learn how to set up the project, create a character, implement movement, add enemies, and manage health and game mechanics. By the end, you'll have a functional game that you can expand upon.

Step 1: Download and Set Up the Project

  • Visit the project files link: Project Files.
  • Download the project files and extract them to your desired directory.
  • Open Godot 4 and create a new project, pointing it to the extracted files.

Step 2: Quick Tour of the Editor

  • Familiarize yourself with the Godot editor interface:
    • Scene panel: where game scenes are managed.
    • Inspector panel: for editing properties of selected nodes.
    • FileSystem panel: showing project files.
    • Output panel: for logs and debugging.

Step 3: Create the Character

  • In the Scene panel, create a new 2D scene:
    • Add a KinematicBody2D node for the player character.
    • Create a Sprite child node to display the character's image.
    • Add a CollisionShape2D child node to define the character's collision area.

Step 4: Add Movement to the Character

  • Attach a script to the KinematicBody2D node.
  • Implement basic movement using GDScript:
    extends KinematicBody2D
    
    var speed = 200
    var velocity = Vector2()
    
    func _process(delta):
        velocity = Vector2.ZERO
        if Input.is_action_pressed("ui_right"):
            velocity.x += 1
        if Input.is_action_pressed("ui_left"):
            velocity.x -= 1
        if Input.is_action_pressed("ui_down"):
            velocity.y += 1
        if Input.is_action_pressed("ui_up"):
            velocity.y -= 1
        velocity = velocity.normalized() * speed
        move_and_slide(velocity)
    

Step 5: Create a Game Scene and Add the Character

  • Create another new scene for the game environment.
  • Instance the character scene into the game scene to have it appear in the gameplay area.

Step 6: Add Game Environment and Collisions

  • Design the game environment with different tiles and obstacles.
  • Use StaticBody2D nodes with CollisionShape2D to create solid objects the player can interact with.

Step 7: Add Mobs that Follow the Player

  • Create a new scene for enemy mobs using KinematicBody2D.
  • Implement basic AI to make them follow the player:
    extends KinematicBody2D
    
    var speed = 100
    var target
    
    func _process(delta):
        if target:
            var direction = (target.position - position).normalized()
            move_and_slide(direction * speed)
    

Step 8: Make the View Follow the Player

  • Use a Camera2D node in the game scene.
  • Set the camera to follow the player character by assigning the character as its target.

Step 9: Give a Weapon to the Character

  • Create a weapon scene and attach it to the character.
  • Implement shooting mechanics in the character script:
    func _input(event):
        if event.is_action_pressed("shoot"):
            shoot()
            
    func shoot():
        var projectile = preload("res://Projectile.tscn").instance()
        get_tree().current_scene.add_child(projectile)
        projectile.position = position
    

Step 10: Make the Gun Detect Aim at Enemies

  • Aim the gun towards the nearest enemy using vector math to calculate the angle.

Step 11: Add Projectiles to the Weapon

  • Create a projectile scene that moves and can damage enemies.
  • Implement projectile behavior in its script.

Step 12: Make the Bullets Damage the Enemy

  • Detect collisions between projectiles and enemies.
  • Reduce enemy health upon collision.

Step 13: Set Up Shooting Mechanics

  • Fine-tune shooting mechanics for better gameplay experience.
  • Adjust projectile speed and damage values as needed.

Step 14: Add Health and Hurt Animations to Mobs

  • Create animations for when mobs are hit.
  • Use animation players to manage mob states.

Step 15: Add Health Management to Player

  • Implement a health system for the player.
  • Display health on the UI.

Step 16: Randomly Spawn Mobs

  • Create a spawn manager to randomly generate enemies in the game scene.

Step 17: Add Game Over Screen

  • Implement a game over state when the player's health reaches zero.
  • Create a UI to display the game over screen.

Conclusion

You have successfully built a simple 2D game in Godot 4, learning key concepts along the way such as character movement, enemy AI, and game mechanics. From here, consider expanding your game with new features, levels, or enhanced graphics. Happy game developing!