void Start ()
{
InvokeRepeating (“Rate”, 0, 2.5f);
}
void Rate()
{
Network.sendRate = 15;
}
Ive tried that, it still didnt work, i have this script that sends an rpc telling where a player is everytime the Vector3 position is different from last position. And it does sends, but instead it sends the rpc twice per second when testing on 2 pc’s even on same machine. Using a Mac OS X maverick with U3D free version
Heres the MovementUpdate.cs ( similar to how M2H does it )
using UnityEngine;
using System.Collections;
public class MovementUpdate : MonoBehaviour
{
private Vector3 lastPosition;
private Quaternion lastRotation;
private Transform myTransform;
void Start ()
{
if(networkView.isMine == true)
{
myTransform = transform;
networkView.RPC("Sync", RPCMode.Others,myTransform.position, myTransform.rotation);
}
else
{
enabled = false;
}
}
void OnPlayerConnected(NetworkPlayer player)
{
networkView.RPC("Sync", player,myTransform.position, myTransform.rotation);
}
void Update ()
{
if(Vector3.Distance(myTransform.position, lastPosition) >= 0.1f)
{
lastPosition = myTransform.position;
networkView.RPC("Sync", RPCMode.Others, myTransform.position, myTransform.rotation);
}
if(Quaternion.Angle(myTransform.rotation, lastRotation) >= 1)
{
lastRotation = myTransform.rotation;
networkView.RPC("Sync", RPCMode.Others,myTransform.position, myTransform.rotation);
}
}
[RPC]
void Sync (Vector3 newPosition, Quaternion newRotation)
{
transform.position = newPosition;
transform.rotation = newRotation;
}
}
Basicly, it should send the RPC called Sync everytime the player moves more than 0.1 units or rotates 1 degree. It does it, but twice per second.
Heres a video : 1 - in the video you can see what i mean, and when the red player health reaches 0, there was a delay.