December 2013
Beginner
242 pages
4h 23m
English
Before we get started, we'll need to restructure our scripts. We're going to change the Update function so that it isn't called automatically, and instead will be called by our networking scripts. We need to do this so that we have direct control over the exact order in which the simulation is stepped, otherwise we can easily end up with desyncs and rubber banding.
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour
{
public float MoveSpeed = 5f;
[System.NonSerialized]
public float horizAxis = 0f;
[System.NonSerialized]
public float vertAxis = 0f;
void Update()
{
if( networkView.isMine )
{
horizAxis = Input.GetAxis( "Horizontal" );
vertAxis = Input.GetAxis( "Vertical" ...Read now
Unlock full access