My server is calculating the speed of a player to the client which is represented as the magnitude of vector x y z. I need to translate the game object by the deltas multiplied by delta time.
My problem is, I’m not exactly doing it right. No errors, just the math isn’t right. Any pointers?
Vector3 targetPosition = new Vector3 (movetoX,movetoY,movetoZ);
Vector3 deltaF = new Vector3 (deltaX,deltaY,deltaZ);
if (deltaF.magnitude != 0)
{
float step = deltaF.magnitude * Time.deltaTime;
transform.position = Vector3.MoveTowards(this.transform.position, targetPosition, step);
}
This is the packet contents Server->Client for reference.
struct PlayerPositionUpdateClient_Struct
{
/*0000*/ uint16 spawn_id;
/*0004*/ float x_pos; // x coord
/*0004*/ float y_pos; // y coord
/*0004*/ float z_pos; // z coord
/*0008*/ float delta_x; // Change in z
/*0012*/ float delta_y; // Change in x
/*0016*/ float delta_z; // Change in y
/*0016*/ float delta_heading; // Change in y
/*0020*/ int32 animationspeed; // animation
/*0032*/ float rotation; // Directional heading
/*0036*/
};
This project is a 3d WebGL MMO.