Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 EasierChutoy · Jan 24, 2014 at 12:35 AM · multiplayerfps

For my multiplayer FPS, the 3rd person character is not moving

I'm currently working on a multiplayer fps which is still in early stages of development. One issue is that the 3rd person character won't move with the player and just stays at the origin. I have the first person controller and 3rd person controller parented to an empty gameobject with the gun and arms parented to the first person controller. When I parent the 3rd person character to the first person controller it follows the controller, but doesn't show up because in my script the first person view isn't viewable by other players.

Here is my only script that is associated with the 3rd person player

  public class PlayerManager : MonoBehaviour 
     {
         public Transform firstPerson;
         public Transform thirdPerson;
         public WeaponManager firstPersonCont;
         public Player userPlayer;
         public Vector3 currentPosition;
         public Quaternion currentRotation;
         public GameObject ragDoll;
         public Player lastShotBy;
         public string lastShotByName;
     
         void Start ()
         {
             userPlayer = NetworkManager.GetPlayer(networkView.owner);
             userPlayer.manager = this;
             firstPerson.gameObject.SetActive(false);
             thirdPerson.gameObject.SetActive(false);
             DontDestroyOnLoad(gameObject);
         }
     
         void Update()
         {
     
         }
     
         [RPC]
         public void FindHitter(string name)
         {
             lastShotBy = NetworkManager.GetPlayer(name);
             lastShotByName = name;
         }
     
         [RPC]
         public void GetKill()
         {
             RankManager.instance.EXP += 100;
         }
     
         [RPC]
         void Server_TakeDamage(int damage)
         {
             networkView.RPC("Client_TakeDamage", RPCMode.Server, damage);
         }
     
         [RPC]
         void Client_TakeDamage(int damage)
         {
             userPlayer.playerHealth -= damage;
             Debug.Log(userPlayer.playerHealth);
     
             if(userPlayer.playerHealth <= 0)
             {
                 networkView.RPC("Die", RPCMode.All);
                 userPlayer.isAlive = false;
                 userPlayer.playerHealth = 0;
                 Instantiate(ragDoll, thirdPerson.position, thirdPerson.rotation);
             }
         }
     
         [RPC]
         void Spawn()
         {
             userPlayer.playerHealth = 100;
             userPlayer.isAlive = true;
             if (networkView.isMine)
             {
                 firstPerson.gameObject.SetActive(true);;
                 thirdPerson.gameObject.SetActive(false);
             }
             else
             {
                 firstPerson.gameObject.SetActive(false);
                 thirdPerson.gameObject.SetActive(true);
             }
         }
     
         [RPC]
         void Die()
         {
             userPlayer.isAlive = false;
             firstPerson.gameObject.SetActive(false);
             thirdPerson.gameObject.SetActive(false);
             lastShotBy.manager.networkView.RPC("GetKill", lastShotBy.onlinePlayer);
         }
     
         void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
         {
             if(stream.isWriting)
             {
                 currentPosition = firstPerson.position;
                 currentRotation = firstPerson.rotation;
     
                 stream.Serialize(ref currentPosition);
                 stream.Serialize(ref currentRotation);
                 char anim = (char)GetComponent<NetworkAnims>().currentAnimation;
                 stream.Serialize(ref anim);
             }
             else
             {
                 stream.Serialize(ref currentPosition);
                 stream.Serialize(ref currentRotation);
     
                 thirdPerson.position = currentPosition;
                 thirdPerson.rotation = currentRotation;
                 char anim = (char)0;
                 stream.Serialize(ref anim);
                 GetComponent<NetworkAnims>().currentAnimation = (Animations)anim;
     
             }
         }
     }
Comment
Add comment · Show 1
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 orlamo · Feb 05, 2015 at 04:57 AM 0
Share

I'm with the same problem... PS:TheFaceGrabber FTW haha

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

yield WaitForSeconds c# 4 Answers

[Closed]multiplayer camera script 2 Answers

Calling the Experts! Problems with Networking: Client/Server Architecture 1 Answer

Machine Learning for FPS game 1 Answer

FPS MultiPlayer 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges