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 savoieric · Nov 24, 2014 at 03:44 AM · photonrpcpunnetwork view

Photon Unity Networking carrying scene objects

I am currently working on an online 2D game where players have to pick up a ball and run around with it. They can also throw it on targets in order to score points or so that other teammates can catch it.

As of now, when a player touches this ball with the arm of his character, it will stick to it and follow him wherever he goes. This is done using the following code in the update function of the arm:

 if (isHolding == true && ToBePickedUp.isHeld == true)
 {
   target.transform.position = transform.position;
 }

isHeld is a public static bool contained in a script attached to the ball object. Whenever the object moves into a player's control zone, the boolean is changed via Remote Procedure Call. I used Debug.Log to make sure this value is changed correctly. This variable is there to let other player instances know the ball is currently held.

When the master client catches the ball, he can run around with it and throw it without any problem. The changes will even be perceived on other players' screens. However, when another player tries to catch or even move the ball around (by running into it with his collider) nothing happens on other players' screens. The ball can ricochet of them if they are in its path however. I'm using the OnPhotonSerializeView function to follow the ball's movement.

alt text

This first image shows the view on the green player's screen (red player is the master client).

alt text

The second one shows the view on the red player's screen.

When the green player releases the ball, it immediately returns to the position on red player's screen. The network manager has been largely inspired by the one showed on quill18's tutorial. I have looked at the DemoPickup from the Photon package but could not find an answer. I also looked on unity answers before posting. This investigation led me to think some missing RPC prevents the network from following the ball when it's position is modified by the green player. I spent hours trying to find where to put it without success so I'm begenning to think this might not be the issue after all.

Any help would be much appreciated!

serverclient1.png (3.1 kB)
serverclient2.png (2.2 kB)
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 tobiass · Dec 02, 2014 at 05:20 PM 0
Share

As side note: I have a hard time finding the essence of your post. What exactly you can't solve or want answered.

1 Reply

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

Answer by tobiass · Dec 02, 2014 at 05:32 PM

The owner of a PhotonView is the one who writes updates in OnPhotonSerializeView.

The trick in the Demo Pickup (in the PUN package) is that the pickup-items don't really move. The droppable item has a special RPC that sets the position when it gets dropped at some place but otherwise the object doesn't move.

The problem in your case is "ownership". The player who Instantiates the ball will own it. If it's a scene object (loaded with the scene but having a PhotonView), the Master Client owns the object.

You want one player to pick up the item, move it and this player can decide where the object is.

PUN 1.28 doesn't allow you to take control of objects this way. This is a feature in the upcoming release.

You could try to work around the problem by not synchronizing the position in OnPhotonSerializeView. Instead use RPCs. You know who has the ball and who can shoot it. The player who is in control might send RPCs to shoot the ball and to update the other.

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 savoieric · Dec 06, 2014 at 10:33 PM 0
Share

Hello Tobiass,

Thank you for taking the time to answer my question! I realize I might not have been clear on what I wanted solved, but you seem to have grasped my problem quite well juging by your answer.

From what I can understand, the best way for me to work out the problem would be to destroy the ball object when it's picked up using RPC's and have the player who did it instanciate a new ball when he shoots. Is that what you meant in your last paragraph?

Also, since only the $$anonymous$$aster Client owns scene objects, could it be a good idea to make the player who picks up the ball the $$anonymous$$aster Client or the previous $$anonymous$$aster Client would still be considered the one who instanciated the object?

Finally, you mention the feature I'm looking for will be in the upco$$anonymous$$g release. Is there an estimated time of arrival for this release?

Thanks again for your time, your answer is already very helpful!

avatar image tobiass · Dec 09, 2014 at 02:03 PM 0
Share

The new feature is in PUN v1.50 and up (in the Asset Store).

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Photon PUN2, Rpc score can't correctly. 1 Answer

Sending int value owned by Masterclient to other client 2 Answers

Photon RPC relationship question. 0 Answers

I'm trying to generate a random key and share it with other players when they join the game i'm using PUN. it's not working please help! 0 Answers

Photon PUN 2 RPC function doesn't change a variable value 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