- Home /
[UNET] Replace sprite for local player's playerprefab through UNET
Hi, I'm Sherlore and I'm new to Unity Answers, so please forgive me if I do anything improper.
Recently, my friend and I need to design a teaching material for our student. To make our students be able to design their own character. We want to make a game that player can have an avatar and meet each other through UNET. And the students can change their avatars' appearance by giving them whole project and teach them how to edit sprite.
Since the students only change the sprite and we don't want to spend time on merging all new avatar into one application, we wish the project and game can work like below
1.Student open project and edit sprite only.
2.export application of one's own.
3.start networking connection
4.the player with local player authority can synchronize new sprite to his/her avatar //The example will be given later.
After some testing, we found if you only edit sprite of the playerPrefab, UNET would still view them as same playerPrefab. So if I export first version and then edit sprite(e.g. change body to red) to export second version, the networking game would like
And for the example we want to achieve, if left window is the local player of left role and right window is the local player of right role, we want to make left role in left window synchronize his red body sprite to left role in right window and right role synchronize his blue body in opposite way.
I have tried using Command with sprite as parameter. It didn't work. The sample code is
public SpriteRenderer bodySP;
void Start ()
{
if (!isLocalPlayer)
{
return;
}
CmdUpdateSP(bodySP.sprite);
}
[Command]
public void CmdUpdateSP(Sprite ss)
{
bodySP.sprite = ss;
}
Looking for any good advice. The possible solution or other approaching are all welcome. Thanks!!
Your answer
Follow this Question
Related Questions
Sending image data through SyncVar doesn't work (Mirror Networking) 0 Answers
Fliping 2Dsprite over network,fliping 2Dsprite from client to server not updating 0 Answers
Flipping Sprite on Client/Over Network 0 Answers
Flipping sprites in Multiplayer doesn't flip host 2 Answers
Unity Lobby Networking - Change player RuntimeAnimatorController and sync? 0 Answers