hey guys i am in progress of making a multiplayer game and i was searching for networking animations,so i have some questions,if you create an animation state system and send only animation state information is it going to suck up bandwith?if yes i reading something like handling animation with client by checking velocity rotation and position. how is that possible in the update function? can anyone give a small example?
First off, you might be better off asking in the networking forum. With regards to networked animations (assuming you're using default networking), the quickest way to get it working is by using OnSerializeNetworkView, and send the players local animator variables if the stream is writing (=the data that is serialized to the network), and then read and set those animator variables within an "if(stream.isReading)" statement. Alternately, you could just get Bolt which does all of that for you automagically
this is good for mecanim,in legacy animation i think its going to desync with high ping,im more interested in this : Prediction Based Animation Post By : MWMDragon Here is a simple explanation: The way that Prediction based Animation works is that the game will set the animation that the player should be playing based on their movement.. If the player is moving forward then the player model will show the walking animation, if they are moving up, show the jumping animation. There is no Network overhead (Bandwidth Use) because nothing needs to be sent to the server or the clients, because the animation as it is being predicted and shown by each client playing. With the animations already stored in each clients game files, no information needs to be sent. Animations being predicted by all clients playing the game.. job done! topic : http://forum.unity3d.com/threads/what-is-the-best-way-to-send-an-animation-over-a-network.133785/ i cant understand how is it possible because if u store the position in a variable, in the update function it is going to update everytime and change automaticaly.so how is it possible to see if character is moving or not without networking? thats why i need an small example.
Code (CSharp): using UnityEngine; using System.Collections; public class PredictAnimation : MonoBehaviour { private Vector3 m_lastPos; public void Update() { Vector3 curPos = transform.position; //get position this frame Vector3 velocity = curPos - m_lastPos; //calculate direction from last frame to this frame Vector3 descaledVelocity = velocity / Time.deltaTime; //de-scale by time float speed = velocity.magnitude; //length of velocity = speed float descaledSpeed = speed / Time.deltaTime //extrapolated speed over 1 second worth of frames velocity = velocity.normalized; /* equivelant to transform.forward, but relative to movement instead of character orientation */ Vector3 predictedPos = curPos + velocity; /* this is only predicting one frame in front, this is also known as extrapolation */ Vector3 descaledPredictedPos = curPos + descaledVelocity /* this is predicting one second worth of frames in front, this is also known as time based extrapolation */ //velocity = unscaled velocity between last frame and this frame //descaledVelocity = velocity extrapolated for 1 second worth of frames //speed = speed measurement between last frame and this frame //descaledSpeed = speed measurement estimation for 1 second worth of frames //predictedPos = extrapolated position for next frame //descaledPredictedPos = extrapolated position 1 second into the future m_lastPos = curPos; //store position this frame for the next frame } } Hope this helps!
this is very good thanks for helping me !! but the only problem is that i dont know complex english words and even with translator i cant understand but with some practise and search i will understand! thank you so much again!