How to Build a Competitive Online Racing Game Using Unity and Redis
Published: 2021-11-29 09:12:13

---
title: How to Build a Competitive Online Racing Game Using Unity and Redis
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
---

If you’re into gaming and love creating things, then you may take inspiration from this Launchpad App. By using Redis, Graham Pinsent created his very own online racing game where friends, family, and colleagues can settle old scores and compete against each other for the finish line. 

Just like any racing game, the ultimate objective is to get from A to B in the fastest possible time. Players are given a car, times are contested, and the winner is decided based on whoever can zoom through each lap the fastest.

But for this application to function optimally, data must be transmitted with hyper-efficiency to ensure player commands are carried out in real time. Failing to achieve this would create a disconnect between the player’s commands and their in-game vehicle, leading to a frustrating gaming experience. 

To prevent this from happening, Graham leveraged Redis’ advanced capabilities to create an application where components are able to seamlessly transmit data between one another with maximum efficiency. 

Let’s investigate how this was done. We also have a variety of exciting applications created by the Redis community for you to check out. Make sure to catch all of the action on the [Redis Launchpad](https://launchpad.redis.com). 

<iframe width="812" height="457" src="https://www.youtube.com/embed/Tq3yoIn4hLc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>


- What will you build?
- What will you need?
- Architecture
- Getting started
- How it works

## 1. What will you build?

You’ll build an online racing game that allows players to compete against each other using Redis. Below, we’ll go through each stage chronologically and highlight what components you need to bring this application to life. 

Ready to get started? Ok, let’s dive straight in. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l6sw001l7jzzt3twgxor.png)
 



## 2. What will you need?

- NodeJS: used as an open-source, cross-platform that executes JavaScript code outside a web browser
- Express: used as a flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
- Unity: used as a real-time development platform for video games
- RedisJSON: implements ECMA-404 The JSON Data Interchange Standard as a native data type.

##3. Architecture

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pqns902r0v2btbwupe1a.png)
 

After every 0.1 seconds, the position of each user’s car is sent to the Node JS server.
Node JS processes this data and sends it to the Redis database.
The server then sends the position of each user’s car and updates their position.
The time of each lap completed by a user will be sent to the Node JS server to be added to the live leaderboard in the Redis database. 

## 4. Getting started

## Prerequisites 

- Node.js
- NPM
- Unity 2020.3.4f1
- Redis with RedisJSON module

Read the complete blog [here](https://redis.com/blog/how-to-build-a-competitive-online-racing-game-using-unity-and-redis/)