I have a cube in my game that lerps between its initial state and a larger state while looking at another object. This works fine in single player, but when I bring it over to multiplayer I can't find the right combination of options to get it to update on both clients (one being host). Each player can activate their own cube still but is not represented on the other machine. The script is on the button which has a network identity and it accesses the cube which also has a network identity and a network transform.
Single player code reference:
void Update () {
if (Camera.main != null) {
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit)) {
if (hit.collider.gameObject == gameObject && hit.distance < 5) {
PlatformScale();
} else {
PlatformReset();
}
}
}
}
void PlatformScale () {
platform.transform.localScale = Vector3.Lerp (platform.transform.localScale, platformScale, 3f * Time.deltaTime);
}
void PlatformReset () {
platform.transform.localScale = Vector3.Lerp (platform.transform.localScale, platformStartingScale, 3f * Time.deltaTime);
}