Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Wolfrik_Creations · Nov 25, 2015 at 08:51 PM · javascriptnetworking

Two questions with mutliplayer

Okay so I use javascript but I can translate C# to javascript if needed. I have a multiplayer game with tag-specific sounds and animations ect everything is fine except for two things.

Problem #1 is that the players teleport around everywhere and I was wondering if there was any way to Lerp between what player1 sees player2 as and where player2 actually is (if I'm not being confusing)

Problem #2 is that it seems a lot of things don't work for clients, only for hosts. Like my car script, the host can get in, drive around, everything. But the clients can only get into a sitting position and they kinda just float in that sitting position around the map. Also clients cannot perform things like changing variables of scripts, it just doesn't do anything but for the host it's fine.

Now one last thing I should point out is that I AM NOT using Unity 5 or Photon (PUN)

I use plain Unity4 code and everything is fine except for those two.

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 Wolfrik_Creations · Nov 26, 2015 at 02:26 AM 0
Share

Okay so I've upgraded to Unity5 and the "Network Transform" component does not work for me and I tried a C# script that seems to work but it sends the client players to the coords (0, [somewhererandom], 0) whenever that player is not moving. When they start moving they start flashing between their position and at 0.

Here's the code: using UnityEngine; using System.Collections; using UnityEngine.Networking;

 public class SyncPlayerPos:NetworkBehaviour {
     [SyncVar]
     private Vector3 syncPos;
     
     [SerializeField] Transform myTransform;
     [SerializeField] float lerpRate=15;
     
     void FixedUpdate () {
         TransmitPosition();
         LerpPosition();
     }
     
     void LerpPosition () {
         if(!GetComponent<NetworkView>().is$$anonymous$$ine) {
             myTransform.position=Vector3.Lerp(myTransform.position, syncPos, Time.deltaTime*lerpRate);
         }
     }
     
     [Command]
     void CmdProvidePositionToServer (Vector3 pos) {
         syncPos=pos;
     }
     
     [ClientCallback]
     void TransmitPosition () {
         if(GetComponent<NetworkView>().is$$anonymous$$ine) {
             CmdProvidePositionToServer(myTransform.position);
         }
     }
 }

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How do I add gravity to my object, and how do I fix my network problem? 1 Answer

More like a bulletin than chat box 0 Answers

Network Chat not sending messages to other clients 1 Answer

Can I connect to a server using the IP adress and the port with the new Unity 5 Networking API?? 0 Answers

unity crashes when script runs 1 Answer


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