Coder Social home page Coder Social logo

unrealcraft's Introduction

UnrealCraft

GIF of playing game

A voxel game made in Unreal Engine 5 using C++, aiming to replicate basic Minecraft functionality. More details about implementation can be found in subsequent sections.

Features

  • Procedurally generated finite voxel world which can be modified by the player.
  • Basic inventory system which allows you to create chests, move items into them, and place items from your inventory into the world.
  • Character which can be controller.
  • Programmed with C++ exclusively.
  • Utilizes DataAssets, UPROPERTY(), Blueprints to make adding gameplay addition easy.

How To Play

Download the latest release for your platform here.

Controls

  • W, A, S, D - Move character
  • Space - Jump
  • E, I - Open/close inventory
  • Left Click - Place Block
  • Right Click - Remove block
  • Mouse Scroll - Change selected block
  • Alt+F4 - Exit Game

Technical Design

Image of generated landscape.

The goal of this project is to ultimately try to replicate basic Minecraft Survival inventory management, block modification, day/night cycle, sounds using C++ and Unreal Engine features to ease the addition of new gameplay elements, such as new blocks or items.

World Generation.

The AVoxelWorld class is the 'manager' class of all chunks (ABaseChunk - potentially for future LOD chunks, like the distant horizons mod). A world of set size is generated with AChunk::GenerateBlocks. Perlin noise is used to generate hills. Afterwards, the topsoil is placed.

Chunk Rendering

Chunks use UProceduralMeshComponent to render themselves. Vertices, UV, etc. are determined at runtime. Face merging was added to reduce the number of vertices.

When a player modifies the chunk, the mesh is reconstructed. Provisionally, the chunks are 32x32x32 to guarantee good performance upon modification.

The textures are stored inside of a Texture2DArray which can have new blocks added easily. EBlock is the backing enum for all blocks.

Inventory System

Image of generated landscape.

The inventory system uses IInventoryInterface as the base for all inventory classes UInventory and UPlayerInventory to ensure easy interoperability between inventories and easy addition of new types/logic. These classes derive from UObject to allow future interoperability with Blueprints. All inventories are stored inside of UInventoryDatabase, a TMap backed data structure.

The inventory is visualized using UInventoryVisualizerWidget. It is ultimately responsible for displaying the player inventory, and/or the world inventory. This uses a UInventorySlotWidget for 'slots', and UInventoryItemWidget to represent the items inside of the inventory.

UItemInfoDatabase (a UDataAsset) contains FUnrealCraftItemInfo, which are defined in engine (inside /Content/Data) to add new items.

UPlayerHotbarWidget visualises a portion of the player's inventory contents. UHotbarCursorWidget gives an animated white box which shows the player's currently selected hotbar slot.

Use of Unreal Structure (GameState, GUI, GameMode)

The inventory info (UInventoryDatabase) and useful references (such as to the UPlayerInventory) are stored in AVoxelGameState.

The APlayerHUD contains all initialization logic and references to core GUI elements, such as the UInventoryVisualizerWidget.

The AVoxelGameMode contains logic to add a player inventory once the player 'joins' (this is not a multiplayer title).

Code Practice

The Epic Games Coding Standard was used throughout. In assets, Blueprints of C++ classes (excluding widgets) have a `BP_`` prefix.

UUserWidget Blueprints use a W_ prefix and C++ classes deriving from UUserWidget contain a Widget suffix.

Image of generated landscape.

unrealcraft's People

Contributors

feliksjakimowkonglomerate avatar giodestone avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.