Question by
Absolute_Sensei · Apr 13, 2017 at 03:18 PM ·
multiplayer-networkingclient-servercheckpoints
How to make checkpoints work on multiplayer client?
I have a checkpoint system for my multiplayer game. Currently, the checkpoints work for the server and not the client. What do I need t change or add into my code to make it work for the client? I'm assuming the problem lies in Checkpoints.cs script but I'm not sure what I need.
This is the code I'm using for the check points:
PlayerControl.cs
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Hazard")
{
RpcRespawn();
}
}
[ClientRpc]
void RpcRespawn()
{
if (isLocalPlayer)
{
transform.position = currentCheckpoint.transform.position;
}
}
Checkpoint.cs
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
playerControler.currentCheckpoint = gameObject;
}
}
Comment
Your answer