Making a simple JRPG (Part 2)

 I spent a few hours trying various ways of quickly importing meshes as a MeshLibrary for the GridMap and eventually settled on a simple post import script which helps me iterate quickly while making my assets.

#import_mesh_library.gd
@tool
extends EditorScenePostImport
# Generate a MeshLibrary from all the mesh in the imported in the scene

const mesh_path: String = "res://Models/Meshes/Tiles"

var meshes: Array[Mesh]

func _post_import(scene):
	var dir = Directory.new()
	if not dir.dir_exists(mesh_path):
		dir.make_dir_recursive(mesh_path)
	
	_iterate(scene)
	_save_mesh_library()
	
	return scene

func _iterate(node):
	if node != null:
		match node.get_class():
			"MeshInstance3D":
				var resource_path = "%s/%s.mesh" % [mesh_path, node.name]
				meshes.append((node as MeshInstance3D).mesh)
			_: pass
	
		for child in node.get_children():
			_iterate(child)

func _save_mesh_library():
	var source_file = get_source_file()
	var file_name = (source_file.get_file()).trim_suffix('.' + source_file.get_extension())
	
	var library = MeshLibrary.new()
	for mesh in meshes:
		var id = library.get_last_unused_item_id()
		library.create_item(id)
		library.set_item_mesh(id, mesh)
	
  ResourceSaver.save("%s/%s.meshlib" % [mesh_path, file_name], library)

Making a game is filled with lots of menial tasks and boilerplates; Exporting assets, importing and preparing them, packaging data, testing out new features and so on. As time goes on and the project grows these will become huge time sink and I'd rather avoid that. It is important, in my opinion, to quickly identify these tasks and automating them, even if it takes some time to do at firsts. Someone once told me

I'd rather send 4 days of a week figuring out how to do the work in 1 day than taking the whole week to do the same work.

 Eventually I will reap the benefit of that automation by being able to quickly add and shuffle content or features in my game.

About my movement issue

Tween to the rescue! I kind of disregarded tween up until now because I always saw these nodes in the context of 2D games and though they weren't available in the 3D context... why, who knows, but I was mistaken! Tween are quite powerful it turns out. Even more now that they no longer are a node you need to add to your scene but a simple reference object you create on the fly! Tons of tweens everywhere from now on!

I've also experimented a bit with the art style in Blender, but I have yet to find a satisfactory look. I've also decided to get two pack from the legendary Kenney, the pattern pack and the foliage pack, in order to develop a style more quickly. The style of those pack is already close to what I'm looking for and it would make little sense to try to create my own texture if it ends up looking similar to what Kenney already did. I still have a lot of input on the final look anyway. I could've taken an 3D tile pack and modified it, however, I still want to get a somewhat unique look so I draw the line at textures.

Just to be clear, using premade assets, especially under CC0, is an excellent way of making games, Kenney makes absolute gems of game asset and not everyone is formed in artistic workflow. Games are the sum of their part, any input you have on the creation of your game makes it that much more unique. Go with your strength and make awesome games!

I've still do have a long way to go, sadly I can't spend more than a few hours a week on this project, but I'm learning a ton of valuable stuff anyhow.
This was a quick update; I hope to have something more substantial next time (Trying to figure a way to get good quality gifs to add too)

Comments

Popular posts from this blog

Making a simple JRPG (Part 1)