- Home /
streaming layerweight onserializeview
hey guys i am struggling with streaming of my layer weight i have multiple layers on my character on my side it works all other animations on the base layer are streaming and receiving but my animation on layer 4 isnt because i cant seem to get this right i tryed google i do know it wants a float weight but i dont understand isnt the float alreddy done in my client/my side ?. ................................................................................................................................................... ......OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)....
stream.SendNext(anim.SetLayerWeight(4, (float)); // this one it says invalid expression term
anim.SetLayerWeight(4,(float)stream.ReceiveNext()); //this one i didnt get error
this is how i did my layer weight
if (isFiringGun == true)
{
currentWeight = Mathf.Lerp(currentWeight, 2.0f, Time.deltaTime); anim.SetLayerWeight(4, currentWeight);
}
if (isFiringGun == false || Input.GetMouseButtonUp(0))
{
currentWeight = Mathf.Lerp(currentWeight, 0.0f, Time.deltaTime); anim.SetLayerWeight(4, currentWeight);
}
Answer by Bunny83 · Jan 23 at 04:36 AM
Well this line:
stream.SendNext(anim.SetLayerWeight(4, (float));
makes no sense on multiple levels. First of all SendNext expects a value that it should serialize and send over the network. However SetLayerWeigth does not return any value, so you can not pass the result to SendNext. Furthermore the second argument of SetLayerWeight should be the weight value you want to set. Though you currently have (float)
there which makes no sense.
If you want to send your current layerweight you either want to send your "currentWeight" value, or if the sending happens on a seperate script, you probably want to use GetLayerWeight instead of SetLayerWeight in the offending line.
hi how are you thanks for the help it worked atleast for the sending part. i dont want to sound verry stupid but i tried the receiving like this and it doesnt work anim.SetLayerWeight(4)stream.ReceiveNext(); i checked https://docs.unity3d.com/ScriptReference/Animator.SetLayerWeight.html and as far as i get it it wants a float anim.SetLayerWeight(4,(float)stream.ReceiveNext()); but still not working all my other animations on the base layer do stream correct and receive ill be honest i am not good at this kind of code for strea$$anonymous$$g :(
Your answer

Follow this Question
Related Questions
Play 2 animations at once 4 Answers
How do I smoothly shift between Layer Weights 2 Answers
[UNET] sending large files over network 0 Answers
Writing binary files on Android 1 Answer
Animation Controller not returning character to correct position. 0 Answers