Closed swapmasterx closed 9 months ago
If you want to swap the character during gameplay, you just have to change the player_character_scene
of the GameMode
to the PakcedScene
of the new character, and the new player will automatically be instantiated. (You can get the current GameMode
with Game.get_gamemode()
Do keep in mind the new character will be instantiated at a spawn point - if you want to keep its position, you can store its original position before the swap, and apply it again after the swap.
Any potential issues with multiplayer implementations? Since it has to change the player character scene in the level. Also do I just put the character scene I want to change to in get_player_characters parentheses or is there more syntax?
To be honest, I didn't use much of Godot's multiplayer yet and don't know exactly how it would interact with untrue. If the spawning and freeing of the character nodes is automatically replicated then there shouldn't be any issues.
And for your second question, the get_player_character
function gets the current player character node, what you want to do instead is set the player_character_scene
variable to your scene.
Having trouble figuring out how to apply the stored player pos for the spectator body. My current code looks like this. It's called from when my hp manager hits 0 and calls this global function but not before grabing the player position and passing it into the die function.
const SPECTATOR = preload("res://character and weapons/classes/Spectator(death_state)/spectator.tscn")
func die(get_player_pos): Game.get_gamemode().player_character_scene = SPECTATOR
In this code you would do
const SPECTATOR = preload("res://character and weapons/classes/Spectator(death_state)/spectator.tscn")
func die(get_player_pos):
Game.get_gamemode().player_character_scene = SPECTATOR
# get_player_character() now returns the new spectator instance
Game.get_gamemode().get_player_character().global_position = get_player_pos
Thank you. You and this plugin are loads of help. Keep up the good work
How would one go about implementing a character change system (like Team Fortress 2's class change system) with tying into Untrue's systems?