Hi,
I’ve been working on a new game project and have gotten to the point where I am separating my assets from the main file and loading them when entering each level using LibLoad. The problem is that it is taking an extremely long time to do this (around four minutes).
My main blend file contains two characters, each consisting of an outer ‘physics cage’ cube and an inner ‘sprite’ plane. The inner plane is swapped out depending on the direction they are facing (using replaceMesh) for another plane (selected from a hidden layer) with different uv coordinates on the main spritemap, which gives the illusion of movement. This part has been working fine with no issues once the scene eventually loads.
The sprite frames for each character are stored in separate blend files, each containing 1024 planes (around 4000 verts for each character). The strange thing is that it takes libLoad around 4 mins to load in these 8000 verts when the game starts, and I have no idea if this is normal - I would have thought that it would have been instantaneous for files of this size.
So, is this unusual? Is LibLoad broken, or am I doing something horribly, horribly wrong?
I’m using:
UPBGE 0.2.3
Linux Mint 18.3
Intel NUC i7, 16 GB RAM
This is the code I am using to import the assets:
import bge
from bge import types, logic
class Level:
def __init__(self, sys):
self.system = system
self.player_libs = {}
self.enemy_libs = {}
self.create_map()
def load_and_merge(self, asset, type):
path = "//resources/" + type + "/" + asset + ".blend"
libraryStatus = bge.logic.LibLoad(path,"Scene")
return libraryStatus.libraryName
def create_map(self):
self.place_player()
self.place_enemies()
def place_player(self):
self.player_libs[identity] = self.load_and_merge("player", "agents")
def place_enemies(self):
scene = logic.getCurrentScene()
spawn_points = [ob for ob in scene.objects if "enemy" in ob]
for p in spawn_points:
if p['enemy'] not in self.enemy_libs:
self.enemy_libs[p['enemy']] = self.load_and_merge(p['enemy'], "mobs")
spawn_obj = scene.objectsInactive[p['enemy'].capitalize()]
new_enemy = scene.addObject(spawn_obj, p)
Thanks!