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 lilsheep · Mar 09, 2014 at 06:41 AM · networkingnetworknetworkview

One user controls all of them on network

When one person moves it animates all people on the server.

This is making everyone walk!

 var view : NetworkView; 
 @RPC
 function walk() { //this function is called when a user presses w
   //print(networkView.viewID);
   view = NetworkView.Find(networkView.viewID);
   view.gameObject.transform.networkView.RPC("isWalking", RPCMode.All);
 }

isWalking just sets a boolean isWalking to true for a specific player object. This is doing it to all of them and I am not sure why!

Also I am getting this usse, perhaps it is related?

NullReferenceException: Object reference not set to an instance of an object networkmanager.spawnPlayer () (at Assets/scripts/networkmanager.js:60)

 function spawnPlayer() { //occurs onConnection and onInitialization
     var viewID = Network.AllocateViewID();
     var clone : Transform;
     clone = Network.Instantiate(playerPrefab, spawnObject.position, Quaternion.identity, 0) as Transform;
     var nView: NetworkView;
     nView = clone.GetComponent(NetworkView); //THIS IS THE LINE WITH THE ERROR
     nView.viewID = viewID;
     
 }
Comment
Add comment · Show 4
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 fifthknotch · Mar 09, 2014 at 07:31 AM 0
Share

Ins$$anonymous$$d of sending RPC's you may just use networkView controllers and check if the networkView.is$$anonymous$$ine. That should keep only the person sending the input able to move only his player, and it is what networkViews were created for...

avatar image lilsheep · Mar 09, 2014 at 07:36 AM 0
Share

What are networkView controllers?

and where should I check is$$anonymous$$ine.

I am sorry, one user controls only himself. The issue is that a boolean is changed that belongs to all of them.

avatar image lilsheep · Mar 09, 2014 at 07:51 AM 0
Share

thank you so much :D :D :D :D :D :D :D :D I will read and digest all of this = ) ! ! !

avatar image fifthknotch · Mar 09, 2014 at 08:06 AM 0
Share

Awesome if it answered your question I will post as answer and you can mark it. :)

1 Reply

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

Answer by fifthknotch · Mar 09, 2014 at 07:46 AM

Check out these docs real quick they outline what networkView controllers are (I say controllers but really they are just components. They are located under "miscellaneous => networkView"), where to find them, how to use them, etc.

http://docs.unity3d.com/Documentation/Components/class-NetworkView.html

You check for networkView.isMine as an if statement surrounding the movement portion of your script. If you do this, you would no longer need RPC's to send player movement because networkView's sync the object transforms across all connected machines

Comment
Add comment · Show 3 · 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 lilsheep · Mar 09, 2014 at 08:19 AM 0
Share

ty again = ) I am stil lreading through it but I am not totally sure. If you don't $$anonymous$$d can you explain 'transforms'?

avatar image fifthknotch · Mar 09, 2014 at 08:21 AM 0
Share

Sure! Transforms hold three sets of data: position, rotation, and scale.

avatar image lilsheep · Mar 09, 2014 at 09:05 AM 0
Share

$$anonymous$$ so I did what you said! The only issue is that it doesn't show when other players move. So on machine A when user A moves, only user A is shown the animation. When user B looks at user A the animation does not display.

 if (is$$anonymous$$oving && networkView.is$$anonymous$$ine){
    child.animation.Play("Walk");
   
   }
   else {
     child.animation.Play("Idle");
   }
 
 function OnSerializeNetworkView(stream : BitStream, info : Network$$anonymous$$essageInfo) {
       var _is$$anonymous$$oving : boolean = is$$anonymous$$oving;
       stream.Serialize(_is$$anonymous$$oving);
   }

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

21 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 avatar image avatar image

Related Questions

How can I get "!networkView.isMine" to function properly? 1 Answer

Client to client Serialization 1 Answer

How do I separate network views? 0 Answers

Network: any way to check in detail the data transmission? 1 Answer

What is Send rate? 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