Categories How To

Making an Open World Car Game in Unity

Start by getting in and out of the car.

To start, you’ll want to use Unity; the Personal version is free and comes in a variety of ‘flavors’.

Get it here. You will download Unity Hub from which you can then select the version.

Unity Hub Installation page after you open the program.
Click “Add” and you will get this popup.

Stick to the LTS version; LTS means Long Term Support. Basically, this is a stable version that will receive fixes and updates.

When you select a version and install it, you can open the Hub again and click the blue “New” button to start a new project. Name your project and set the template to “3D”.

You will enter the Unity Editor and have to wait a few moments for your project to be created. While you wait, go to the Unity Asset Store (FOR SOMETHING FREE) and click on Standard Asset Packs (These may have thumbnails that look like model-kits). Add it to your assets.

This will work for Unity 2018.4 and later.
Window/Package Manager

Once finished, open Window/Package Manager. Select “My Assets” in the filter and then select the Unity Standard Assets plan (type “Standard Assets” in search if you have a lot of assets). If you don’t have it yet, click “Download” at the bottom right. Once complete, import the Camera, Character, CrossPlatformInput, and Vehicle packages into your project. I suggest you also check the Environment and Particle Systems packages.

Standard Asset Packages in Package Manager
Package Manager provides options for how to import. Check Camera, Characters, CrossPlatformInput, Vehicles.

The camera package has three or four cameras that all have their own uses, but what we’re after is the Multi-Purpose Camera Rig. It has a script called AutoCam that will target the transformation that should be followed and that will be played. So moving the mouse or controller stick will allow rotation on the target, similar to Grand Theft Auto.

Characters include a Third Person Character Controller which has everything we need to run around in a scene and which we will use to approach vehicles and enter them.

Cross Platform Input has several input utilities that we may need due to built-in dependencies in the Unity Standard Assets package.

The vehicle contains a Car prefab that has the CarController and CarUserControl scripts that we will use in this project to enter and exit the vehicle.

Error while carrying the package.

This will sound like a joke but Unity’s Standard Assets package imported with errors. The error has been around for years and they haven’t done anything to fix it except include compiler directives (pragma ignore error number [#]) which doesn’t work.

You need to double click directly on the error in the console to enter the script that generated the error.

We will replace the GUIText class with the UnityEngine.UI.Text class and that will delete everything.

Replacing “GUIText” with….
“UnityEngine.UI.Text” will fix the error.

Once the error is fixed, the editor will finish importing all the packages you selected and will compile the script.

At this point we can bring a ground plane to the scene. Right click on the tree tab and add a 3D object/Plane to the scene. Right-click on the Transform plane component in the inspector and click “Reset” to place it at the origin.
Go to the Plane transformation scale component and set the x and z components to 10. The plane is a 10 by 10 meter plane and this will scale it up to 10 (so the size will be 100m x 100m).

Next, in your project folder, you will see the Standard Assets folder and double click on it to see its subfolders. You will see all the sub packages you imported. In the Camera folder, open Prefab and then drag and drop the Versatile Camera Rig into the location. If Gizmos is enabled, you’ll see a camera icon wherever you drop a camera in the scene. However, because the camera is invisible, the only thing you see is the tool.

Now go to the Characters folder and go to the Prefabs sub folder; double-click the ThirdPerson folder and drag and drop the ThirdPersonCharacter prefab onto the plane. Make sure you are using a Third Person Controller and not an AI third person controller. The first one already has plug and play user controls so when you enter Play mode, you can already move around. If you press Play, the camera equipment may automatically target the character and follow him. If that doesn’t happen, click on the camera gear in the Hierarchy tab and look at the AutoCam component. It will have a “Target” field where you will drag and drop a Third Person Character. Now your camera should follow the character around him.

Let’s adjust the values ​​on the Camera Rig before going any further.

Game Online

Gaming Hub

A gaming hub can refer to a central platform or space dedicated to gaming, where players can access games, interact with other gamers, and enjoy related content.

More From Author