- Home /
Question by
LPGaming · May 02, 2013 at 10:01 AM ·
networkingplayerupdating
Problem with player updating.
So, Here's the problem--- Upon connecting to the server for the first time, everything works great, although once you disconnect, or another player joins I then run into the issue where
if(networkView.isMine)
is constantly returning false after the first connection...
Perhaps it's in my code, but here's what I've got.
using UnityEngine;
using System.Collections;
public class MovementUpdate : MonoBehaviour {
//Variables Start___________________________________
private Vector3 lastPosition;
private Quaternion lastRotation;
private Transform myTransform;
//Variables End_____________________________________
// Use this for initialization
void Start ()
{
if(networkView.isMine == true)
{
myTransform = transform;
networkView.RPC("updateMovement", RPCMode.OthersBuffered,
myTransform.position, myTransform.rotation);
}
else
{
Debug.Log("Disabling update");
enabled = false;
}
}
// Update is called once per frame
void Update ()
{
if(Vector3.Distance(myTransform.position, lastPosition) >= 0.1)
{
lastPosition = myTransform.position;
networkView.RPC("updateMovement", RPCMode.OthersBuffered,
myTransform.position, myTransform.rotation);
}
if(Quaternion.Angle(myTransform.rotation, lastRotation) >= 1)
{
lastRotation = myTransform.rotation;
networkView.RPC("updateMovement", RPCMode.OthersBuffered,
myTransform.position, myTransform.rotation);
}
}
[RPC]
void updateMovement (Vector3 newPosition, Quaternion newRotation)
{
transform.position = newPosition;
transform.rotation = newRotation;
}
}
Any help would be greatly appreciated as I've spent over 7 hours trying to figure this out today and finally broke down to ask some questions......
Comment
Your answer
Follow this Question
Related Questions
Players unexpectedly change positions 0 Answers
A node in a childnode? 1 Answer
How to instatiate two players simultaneoulsy before loading level 1 Answer
Add spawn to script [Multiplayer] 0 Answers
yield return WWW; not returning 1 Answer