Hey, is it possible for me to be able to post my project here or somewhere accessible and have someone look over the code? It is pretty small as I am in the early stages of development, and am just panicking about futureproofing and making sure it is understandable for future me.
I don’t know if this is the right place to ask this, but I’m not sure where else to look.
My main issues are:
Where to preload a potentially large number of instance scenes.
Adding instance scenes to groups.
Looking for a better way of telling a scene what “team” it is on. (I don’t want to make two scenes -one for each team- and then have to preload double the scenes)
Quality checks are fantastic if paired with specific questions as you have requested!
If you will use the loaded resource every time, then preload is the best option. If you rarely use the loaded resource, often load is better.
4.3 makes this easier to manage, you can define “global groups” that act the same but are listed in the editor for easy toggling on/off. If you are worried about using groups in code, it’s fine, keep your groups lean they can be expensive operations.
Highly depends on what a “team” is to your game. Sounds like it could be best as metadata or groups if your “team” needs use among multiple different nodes with varying scripts.
the forum is usually there to help with troubleshooting and documenting the results for future use-cases. In your situation, i would refer to #project-help on the Godot Discord server. Of course you can just upload your project onto github or something similar and then try your luck here in the forum.
Most times, you learn things by doing and there is often not the “single right solution”, especially when it comes to structuring code, systems and folders.
I can have a swift look through the project although i am more of use for 2d prototyping games.
Ok, I will attempt to look into this “Load” method you mentioned.
One last question. Through fiddling with the engine, I’ve discovered the ability to create a scene off a blender file (“predecessor”), then create two more scenes off of that first scene (“descendants”) with separate export vars and groups and such. Is this ok? My main worry is telling code which “descendant” to preload (or load?) in which circumstance, but this would prevent me from needing to set a bunch of stuff through code after instancing a scene and cut a bunch of “if then”. Do you have any input?
New inherited scenes are awesome! Use as you see fit, significantly better than duplicating scenes in the filesystem.
load and preload do about the same thing, preload is run sort-of before the game is played. This makes preload faster, but the scene is larger because it has extra resources always tied to it.
Not asking for a full rundown, just a point in the right direction. but is there a way to assign resources to vars, but only load as needed. As I type this out I realize the answer is probably yes, but external input is appreciated.
Great! But you mention “super rare occurrence”. My game could be akin to Pokémon as many characters are to be available, but not all used at once. Would I still preload them all in this case, or use the load you mentioned?
Certainly load in that case, a specific example would help so here’s a random encounter mock up
const route51_pokemon = [ "charizard", "pikachu", "eevee" ] # I do not actually know route51's potential pokemon
const battle_scene = preload("res://pokemon_battle.tscn")
func start_random_encounter():
# only loads one pokemon per encounter
var pokemon_prefab = load("res://" + route51_pokemon.pick_random() + ".tscn")
var pokemon_instance = pokemon_prefab.instantiate()
# always loads the battle scene though
var battle = battle_scene.instantiate()
battle.add_child(pokemon_instance)
add_child(battle)