Question by
wischutz · Feb 10, 2016 at 06:39 PM ·
networkspriterenderersync
How to sync a sprite changed at runtime using UNET?
Hi there,
I'm trying to make a script t change weapons on my unet multiplayer project, but the sprites are not syncing over the network.
Can anybody show me examples? I did'nt find clear information about it anywhere and i can't figure out to do this.
Comment
Answer by Ursinho · Jun 28, 2016 at 04:42 PM
[SyncVar hook("OnChangeWeapon")] string sprName;
void Update()
{
if(Input.GetKeyDown(KeyCode.Q))
{
//change weapon code here
//change only the sprName and 'hook' will make your life beautifull
//remember to put all sprites in Resources folder
}
}
void OnChangeWeapon(string sprName)
{
GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>(sprName) as Sprite;
}
I think it should work, didn't test.
Your answer
Follow this Question
Related Questions
Sync complex variables and components over network 1 Answer
uNet rotation syncing problem 0 Answers
I need help with SyncVar. 0 Answers
Chat 5.5 synclist Stuck 1 Answer
Sync dynamic properties to clients 0 Answers