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 CJay7 · Jan 10, 2014 at 07:37 AM · networkingmultiplayernetworknetworkviewismine

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

Hello,

I am working on a multiplayer game that is being created within a network. So far, everything is working fairly well... Except my networkView. When I open to instances of the game (one in the editor and one in the player), it seems as though the game is wanting to duplicate the player and camera, causing one screen to control the player from the other, and vice versa.

MovementScript.js Code:

 var speed:int;
 var rotateSpeed:int;
 var gravity:int;
 private var cc:CharacterController;
 
 function Start(){
     cc = GetComponent(CharacterController);
 }
 
 function Update(){
     if(networkView.isMine)
     {
         //INITIATE AND MAINTAIN GRAVITY
         cc.Move(Vector3(0, -gravity, 0));
         
         //MOVE FORWARD
         if(Input.GetKey(KeyCode.UpArrow))
         {
             cc.transform.Translate(Vector3(0, 0, 1) * speed * Time.deltaTime);
         }
         
         //MOVE BACKWARD
         if(Input.GetKey(KeyCode.DownArrow))
         {
             cc.transform.Translate(Vector3(0, 0, -1) * speed * Time.deltaTime);
         }
         
         //ROTATE RIGHT
         if(Input.GetKey(KeyCode.RightArrow))
         {
             cc.transform.Rotate(Vector3(0, 1, 0) * rotateSpeed);
         }
         
         //ROTATE LEFT
         if(Input.GetKey(KeyCode.LeftArrow))
         {
             cc.transform.Rotate(Vector3(0, -1, 0) * rotateSpeed);
         }
     }else{
         enabled = false;
     }
 }

Does anyone know where I might be going wrong?...

Comment
Add comment · Show 6
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 CJay7 · Jan 10, 2014 at 08:48 AM 0
Share

BU$$anonymous$$P

avatar image nastasache · Jan 10, 2014 at 08:56 AM 0
Share

How you instantiate the player? With Instantiate(), or with Network.Instantiate()? You have to verify the owner of NetworkView to be different in both instances.

avatar image CJay7 · Jan 10, 2014 at 08:59 AM 0
Share

I'm sorry. I'm fairly new to the Unity thing, so I don't quite understand what you mean...

avatar image nastasache · Jan 10, 2014 at 09:47 AM 0
Share

You have to read a bit more the tutorials about how the networking it's working on Unity. Networking is not an easy thing and there are more ways to create and control objects from a machine/unity instance to other. The idea is the object having attached NetworkView have an owner. The owner is the creator of object, aka Unity instance (editor,player) which create (instantiate) the object from the project on the scene. If use Network.Instantiate, the owner is Unity instance sending call to other Unity instances to create object. If use Instantiate and use RPC to other Unity instances to create the object, than each Unity instance will create the object in local scene, so each Unity instance will be the owner, we having more owners. 'is$$anonymous$$ine?' mean 'I am owner?' so that game logic have to take care about who created the object. It's a good idea not to drag an object on the scene expecting it just to be easy controlled over network, but use instantiation ins$$anonymous$$d, cloning objects from project hierarchy. Look on your code for 'Instantiate'. I hope this give you a direction.

avatar image CJay7 · Jan 10, 2014 at 03:11 PM 0
Share

I have instantiated the object. A cloned object is created when I join the server as a client. I also use the "networkView.is$$anonymous$$ine" code in my $$anonymous$$ovementScript.js. I'm not sure why my code is not functioning properly.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by CJay7 · Jan 13, 2014 at 06:59 AM

I have solved the problem with my network. I will try to remember to post my solution tomorrow.

Comment
Add comment · Show 2 · 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 khos85 · Oct 01, 2014 at 09:15 PM 0
Share

What was your solution :) ,I know this is an old thread but might help me/others..

avatar image Miscellaneous · Apr 11, 2015 at 11:30 PM 0
Share

Agree with khos85

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

20 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

Related Questions

Unity networking tutorial? 6 Answers

Sending and receiving variables trough network? 2 Answers

Networking dupplicate processing of components 0 Answers

[uNet] Need help Converting From Unity Network to uNet 0 Answers

Photon PUN, HTC Vive camera prefab over network instantiation 0 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