APPLICATIONS

How to Import Assets in Godot

Some of us are artistic, some of us are technical. A gifted few are both. But, if you’re like me and are more on the technical side, then it’s likely you’ve decided to make a game or project, and then thought, how am I going to make it look good? The answer to this is inevitably searching on the likes of Sketchfab or TurboSquid for some free assets to bring your idea to life. At least in the concept stage.

But then comes the second problem, importing them to your engine of choice. When working in Godot, there are a few nuances you need to be aware of when importing assets, and in this tutorial, you’ll go over them in order to create a main menu scene for a horror game.

Getting Started

For this, there’s no starter project, but you can still download the final project from the links at the top or bottom of this page. Go ahead and create a new project in Godot using the default settings. For your main menu prototype you’re going to need four different types of assets imported:

  • A static model to use as the scene.
  • An animated character model.
  • A texture to use as a title logo.
  • Two audio clips.
    • Background music.
    • An eerie sound effect.

By the end of the tutorial, you should have something that looks a little like this:

Supported File Types

According to the list of features, Godot only has a limited type of file formats that it supports with imports. In terms of image formats, Godot does support most of the standard formats. But for audio, you’re limited to:

Using Different 3D Model Types

For 3D model formats, Godot really recommends you use the glTF format. Its full list of supported formats are:

  • glTF 2.0.
  • .blend.
    • However, this is only supported by blender calling a glTF formatter at export.
  • FBX.
    • This file format is supported natively by Godot since version 4.3.
  • Collada (.dae).
  • OBJ.

You may be familiar with some of these formats, but you can see that Godot really wants you to be using the glTF format. Another file type you’ll see around the asset libraries is GLB. GLB format is just a binary representation of the same data as glTF format, so in this regard, Godot can work with either format.

Importing 3D Models

For this project, you should open a blank Godot project. The 3D models that you’re going to import in this tutorial are included in the project materials, or you can simply download them directly from the source.

3D Environment

To take a look at the different import types, you’ll look at both a GLB and a glTF import for this tutorial. You’re looking for a spooky, ‘Stranger Things’ style environment, so this Abandoned Warehouse – Interior Scene by Aurélien Martel on Sketchfab is the ideal starting point. When you click the download it’s available as both glTF and GLB, but for the purposes of the tutorial, download the GLB format, or find the asset in the materials folder under the GLB folder.

Abandoned Warehouse – Interior Scene by Aurélien Martel on Sketchfab

Right-click on the res folder in the File System view, and create a new folder in your Godot project called Models, and then another subfolder called GLB. Right-click on this new folder and select Open in File Manager. Drag or Copy the abandoned_warehouse_-_interior_scene.glb file into the GLB folder and then return to the Godot editor.

Godot will start to import the file:

Godot import dialog

Once the import process is complete, you’ll have a lot of texture files in the folder along with the actual .glb file.

Imported GLB

Double-click on the .glb file and the imported scene will open up in a new window for you to check out.

GLB file editor

Editing Scenes

When working in Godot with multiple assets, it’s best to set them up as individual scenes for editing later. A game in Godot is typically composed of multiple scenes, loaded at the same time. From the top menu, click the + icon to create a new scene, and choose 3D Scene as the root node.

Create a new scene

With the new scene open, drag the imported .glb from the FileSystem window onto the root node in the Scene window. This will instantiate your model in this scene. Save this scene with the name Environment.

Saved first Godot scene

Animated 3D Model

While the environment import was nice and simple, you’ll try something a little more complex for the next import. What’s a ‘Stranger Things’ inspired scene without the introduction of an iconic monster? For this you’ll import the Demogorgon Rig by NO DONT EAT ME CASEOH (Ferris wheel) again from Sketchfab.

Demogorgon Rig by NO DONT EAT ME CASEOH (Ferris wheel) on Sketchfab

This time, download the glTF format model or find it in the tutorial materials folder. Create another subfolder under the Models folder called GLTF and copy the entire folder demogorgon_rig there. Open Godot to allow the asset to import like before.

Open the scene.gltf file that’s now in the Models ▸︎ GLTF ▸︎ demogorgon_rig folder.

Imported glTF file

Here you’ll see that the model is a little more complex, broken down into various different meshes, including a skeletal rig. This is essential for the model to be animated, but thankfully, it’s all set up for you already.

Advanced Import Settings for Scene 'scene.gltf'

Also imported in this scene view are a number of different animations included in the asset. You can run through them all to take a look, but for the tutorial you’ll use just one of these.

Create a new scene as you did before for the environment, again with a 3D Scene as the root node. Rename the node as Demogorgon. This time, drag the ModelsGLTF ︎▸ demogorgon_rig ︎▸ scene.gltf onto the root node. This will instantiate the model as Sketchfab_Scene, but only as a single static model Node3D.

Right-click on the Sketchfab_Scene node and select Editable Children.  Once you do, all the nodes from the asset will appear in the Godot scene.

Asset Import - Editable Children

With the nodes now editable, select the AnimationPlayer node and look for the Current Animation field in the Inspector panel. Use the dropdown to select the IdleHunt animation to see the model animating in place.

Animation Player settings

The animation only plays once. It’s designed to loop, however, and this is what you want for the menu scene. Find the Animation Player window at the bottom of your view, and toggle the Loop button.

Toggle the loop button

Uh oh, did you get the following error dialog?

Can't edit animation

In order to change any properties of the animation in Godot, you first need to change the import settings for that animation. Save the current scene file as Demo.tscn and once more open the source scene.gltf file.

Fold out the AnimationPlayer from the source scene. Find the IdleHunt animation in the list and select it. In the right-hand settings panel, set the Loop Mode to Linear. Then, enable the Save to File option and click the folder icon to set a path to save to. Create a new folder in the root of the project called Animations and save the file as Idle.res. Click Reimport at the bottom of the window to save these import settings.

Advanced Import Settings for Scene 'scene.gltf'

Return to the Demo.tscn window and select the correct animation from the drop-down again. Try to toggle the loop mode of the animation and this time you won’t get the error and you’ll see the animation now plays on repeat.

Save the Demo.tsn file again.

OK, now that you have a couple of scenes set up, it’s time to combine them into the scene that will actually be used to comprise the menu scene of the prototype.


Source link

Related Articles

Back to top button