• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by RichieJ · Oct 07, 2014 at 04:07 AM · spawningfloating

Player Model Floating after Spawn

Hi, I've been following this tutorial.

https://www.youtube.com/watch?v=yxt6Nbxk8Hw

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 controller

http://imgur.com/1YOLXN9 playmode http://imgur.com/JIw0aIY nonplaymode1 http://imgur.com/Jhf6tym 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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by theANMATOR2b · Oct 07, 2014 at 03:29 PM

Hey Richie I know this is a simple (non coder) answer and you've probably already tried this but it looks like your character mesh should be roughly centered in the middle of the character capsule collider instead of at the top of it. http://docs.unity3d.com/Manual/class-CharacterController.html

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RichieJ · Oct 09, 2014 at 01:29 AM 0
Share

Thank you, I was changing the location of the graphics within the collider.. I was forgetting to hit apply after.

Thanks, Richie

avatar image
0

Answer by conceptfac · May 09, 2019 at 04:45 AM

Here is happening the same problem, but offline mode all is normal

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

JS: Access var inside class 1 Answer

How can I grab the position of an object, use it for the instance of a prefab and change the y position of it? 1 Answer

Transform.position without Vector3? 1 Answer

Object Spawning Too Low 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges