Finding the "correct" method of adding different character scenes to a world based on a menu choice

Godot Version

4.2

Question

I want to make a game with character choices. I am currently under the impression that I should create a basic character scene, that based on menu action, has a child scene containing specific character stuff added to it.

So basically. I have a generic scene with a characterbody and a script which will call down to it’s to-be-added specific scene containing mesh and specific character functions.

This should work as long as I’m careful, but I’m mostly worried about where to store all the needed scene references. do i just add a bajillion preload vars to the basic script, is that ok?

Also is this even the right way to do it or should I pivot before I go to far with this?

Further Info.

The basic character scene is placed within an arena world scene. When switched to from a menu, that scene is told what character data to instantiate as a child of the basic scene.

This is my method of trying to uniform the characters, having them all technically be controlled from one single scene, which calls to it’s child containing all the specifics, which when called controls the main.

I guess the ultimate question is do I use Instantiation to do this, and where do I store the references.

Yes, your characters should always be on separate scenes. You can just do right click->Save Branch as scene if you already started working on your main arena.

If you have some sort of character selection screen, you could just store a variable with the character position, then instantiate the new character and then free the last character and place the new character on the position of your old character.

Something like this:

extends Node2D
const CHAR1 = preload("res://CharactersFolder/char1.tscn")
const CHAR2 = preload("res://CharactersFolder/char2.tscn")

var current_character : Node3D

func change_character():
	var last_character_position = current_character.position
	var new_character = CHAR2.instantiate()
	current_character.queue_free()
	current_character.position = last_character_position
	current_character = new_character
	add_child(new_character)
	

Ok thanks! Not quite what I was looking for but it seems I was looking for an overcomplicated solution! One last thing. Is it ok to have a bunch of preloads if I’m working with a large variety of assets? Or is the performance cost minimal?

You could just load them on demand, using load(). Otherwise they’d probably take a long time to load. Like, for instance, if you have like fifty 3D characters it’s probably better to just load them on demand, when the player selects one character, you load them there, instead of preloading all 50 characters for no reason.
You could preload the character portraits, which is lightweight and then when the player selects the character, then you load() them.
I don’t know if I’m making myself clear.

That makes sense. Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.