How to assign a random sprite to a player?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kdenning

Hi,

I am creating a multiplayer game where players join a lobby. When a player joins, I want a random Animated Sprite from a list to become their sprite.

I have a parent node I’m calling Party. Could I preload all the sprites in that node and then assign them to players as they join? I’m not sure the best way to go about this.

Thanks!

:bust_in_silhouette: Reply From: Andrea

simplest solution that come to my mind: move the sprite around the game tree using

Party.remove_child(sprite_node)
Player.add_node(sprite_node)

I like this idea. I think I could preload the sprites as PackedScenes and then add them as children to the Player nodes when the players join.

kdenning | 2020-06-01 14:05