- Home /
Unity Network, smooth interaction between client and server player objects
Simply I created a sphere(ball which including physics material) as player and added the movement scripts which is below. And i checked the local player authory for player object. Then i host a game and join the room with another player. My problem is when i hit the host player with client player, i cannot move other player smoothy. When i unchecked the local player authory for player i can move other player smoothy but this time client player moves laggy, not perfect same as host player. My question is what i need to do for perform smooth movement for both players and when hit eachother work physics regular.
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class PlayerController : NetworkBehaviour {
public float speed;
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate ()
{
if (!isLocalPlayer) {
return;
}
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}
}
Your answer
Follow this Question
Related Questions
Since switching to using offline & online scenes in the NetworkManager, Clients will not sync (UNET) 0 Answers
Moving another player character on Network 1 Answer
Trying to store a variable for all clients 0 Answers
Smooth transform 2 Answers
[Unet] NetworkServer can not assign local player authority after a scene change 0 Answers