Hi, I’ve been following this tutorial.
I'm trying to do the create fps multiplayer but now that I have set everything up. My character is now floating in the air. Before I added the Model to my player controller my character was spawning on the ground, I think but just as a capsul. This is what it looks like now. after I have added the model to my player controllerImgur: The magic of the Internet playmode
Imgur: The magic of the Internet nonplaymode1
Imgur: The magic of the Internet nonplaymode2
Here is the Network Manager script
using UnityEngine;
using System.Collections;
public class NetworkManager : MonoBehaviour {
public GameObject standbyCamera;
SpawnSpot[] spawnSpots;
// Use this for initialization
void Start () {
spawnSpots = GameObject.FindObjectsOfType<SpawnSpot> ();
Connect ();
}
void Connect() {
PhotonNetwork.ConnectUsingSettings ( "MultiFPS v001" );
}
void OnGUI() {
GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
}
void OnJoinedLobby() {
Debug.Log ("OnJoinedLobby");
PhotonNetwork.JoinRandomRoom ();
}
void OnPhotonRandomJoinFailed() {
Debug.Log ("OnPhotonRandomJoinFailed");
PhotonNetwork.CreateRoom (null);
}
void OnJoinedRoom() {
Debug.Log ("OnJoinedRoom");
SpawnMyPlayer ();
}
void SpawnMyPlayer() {
if (spawnSpots == null) {
Debug.LogError ("WTF");
return;
}
SpawnSpot mySpawnSpot = spawnSpots [Random.Range (0, spawnSpots.Length)];
GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate ("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
standbyCamera.SetActive (false);
myPlayerGO.GetComponent<FPSInputController>().enabled = true;
myPlayerGO.GetComponent<MouseLook>().enabled = true;
myPlayerGO.GetComponent<CharacterMotor>().enabled = true;
myPlayerGO.transform.FindChild ("Main Camera").gameObject.SetActive (true);
}
}
Here is NetworkCharacter Script
using UnityEngine;
using System.Collections;
public class NetworkCharacter : Photon.MonoBehaviour {
Vector3 realPosition = Vector3.zero;
Quaternion realRotation = Quaternion.identity;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (photonView.isMine) {
// Do nothing -- the character motor/input/etc... is moving us
}
else {
transform.position = Vector3.Lerp (transform.position, realPosition, 0.1f);
transform.rotation = Quaternion.Lerp (transform.rotation, realRotation, 0.1f);
}
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
if(stream.isWriting) {
// This is OUR player. We need to send our actual position to the network.
stream.SendNext (transform.position);
stream.SendNext (transform.rotation);
}
else {
// This is someone else's player. We need to receive their position (as of a few
// millisecond ago, and update our version of that player.
realPosition = (Vector3)stream.ReceiveNext();
realRotation = (Quaternion)stream.ReceiveNext();
}
}
}
Here is spawnspots script
using UnityEngine;
using System.Collections;
public class SpawnSpot : MonoBehaviour {
public int team=0;
}
The white blox are my spawnspots
please if you can help me I’ve been stuck here a while… Thank you very much.
Also, if you need any more information please let me know.
Richie