Photon target character not connected
I'm using photon to make my game multiplayer and i want to control my character so on the "OnJoinedRoom()" function in my NetworkManager c# script i tell the camera to attach the newly spawned character to the "Target" Gameobject. It gets attached but i get an error: UnassignedReferenceException: The variable Target of characterMovementScript has not been assigned. You probably need to assign the Target variable of the characterMovementScript script in the inspector. characterMovementScript.Update () (at Assets/scripts/characterMovementScript.cs:30)
My script NetworkManager: using UnityEngine; using System.Collections;
public class NetworkManager : Photon.MonoBehaviour {
Vector3 vSpawn = new Vector3(0, 20, 0);
// Use this for initialization
void Start () {
PhotonNetwork.ConnectUsingSettings ("alpha 0.1");
}
void OnGui(){
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
}
void OnJoinedLobby(){
PhotonNetwork.JoinRandomRoom ();
}
void OnPhotonRandomJoinFailed(){
PhotonNetwork.CreateRoom (null);
}
void OnJoinedRoom(){
GameObject myCharacter = PhotonNetwork.Instantiate ("character", vSpawn, Quaternion.identity, 0);
Camera.main.GetComponent<characterMovementScript> ().Target = myCharacter;
}
// Update is called once per frame
void Update () {
}
}
relevant part of my characterMovementScript:
public GameObject Target;
....
Target.transform.position = Vector3.MoveTowards (Target.transform.position, targetPosition, Time.deltaTime * smooth);
@ dhore
Sorry man, I've never used Photon Networking so I don't think I can help you out here...