- Home /
This question was
closed Oct 07, 2017 at 11:08 AM by
omerselman for the following reason:
Other
Question by
omerselman · Oct 05, 2017 at 06:31 PM ·
networkingmultiplayerserverclientcommand
Multiplayer push object error.
Guys, This is a piece of my script for kicking the ball. Server player kicks allright, adds force as much as pressed to key. Client player has some problems. First of all it kicks the ball but doesnt add force as much as key pressed, min force applies. Also server dribbles okay but after kicking the ball several times, client and server lose sync of the ball until server player catches the ball. Any idea about what is wrong ? I am not using parenting to player for dribbling the ball but pyhsics with script. Thanks
void Update ()
{
if (Input.GetKey(KeyCode.C) && canShoot == true)
{
timePressed = counter += Time.deltaTime * multiplier ;
Debug.Log("pressed");
}
if (Input.GetKeyUp(KeyCode.C))
{
if (canShoot == true)
{
hitSpeed = 1 * timePressed;
CmdshootingBall();
timePressed = 0f;
counter = 0f;
}
Debug.Log("reliesed");
}
}
[Command]
void CmdshootingBall()
{
RpcShootBall();
}
[ClientRpc]
void RpcShootBall()
{
shootball();
}
void shootball()
{
sphere.GetComponent<Dribbling>().owner = null;
sphere.gameObject.GetComponent<Rigidbody>().velocity = new Vector3(transform.forward.x * hitSpeed, 5.0f, transform.forward.z * hitSpeed);
canShoot = false;
Debug.Log("I shoot");
}
Comment