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 JonJohnson · Feb 26, 2012 at 12:05 AM · networkingmultiplayernetworkviewflashlight

Multiplayer Flashlight Issue

I have a multiplayer FPS where local player character has a flashlight made from a spotlight attached to a cylinder . The Remote Player Prefab also has the same flashlight. The flashlight is controlled by a simple on/off script.

When running the multiplayer test each player can switch on his flashlight and the flashlight projects a beam onto an object when viewed in that players game window. However the other players cannot observe the flashlight or it's beam.

I don't really have an in-depth understanding of networked multiplayer games but understand that the other players observe the RemotePlayer Prefab rather than local player. I presume that activating the on/off script on the local player (pressing f) doesn't affect the RemotePlayer Prefab in the same way (even if it has the same script attached).

How do I get the RemotePlayer Prefab flashlight to reflect the same on/off state as the local player? Is this a role of RPC's? I have tried placing a NetworkView on the spotlight with no success. Any guidance would be appreciated.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by syclamoth · Feb 26, 2012 at 03:45 AM

If you have a networkView set to observe a custom script, you need to manually override OnSerializeNetworkView to tell it what information needs to get sent.

If you do so, you need to make sure that both sides of the connection have the same type. While any networkView will connect to every other networkView with the same NetworkViewID, you will have problems with RPCs etc. if both sides don't have the same functions available.

Basically, unless you actually tell the game to send information to the other clients, they simply won't get updated. That is all. If you are using Transform or Rigidbody synchronisation, I would recommend implementing some kind of interpolation or extrapolation instead, so that you don't get jerky remote player movement.

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 JonJohnson · Feb 26, 2012 at 09:18 AM 0
Share

Thanks for the quick response. Again I may misunderstanding how Unity works so excuse me if what I'm about to say is stupid.

Both the RemotePlayer Prefab and the local player are set up with the flashlight & script. The RemotePlayer Prefab is a carbon copy of the local player but with a physical body mesh (rather than a camera). As i understand it the RemotePlayer Prefab is used in the $$anonymous$$ultiplayer game to represent the actions of the local player to all of the other networked players i.e. the local player moving is replicated by the RemotePlayer Prefab so all the other players can see what each player is doing. $$anonymous$$y game transmits all movement data fine - including animations (using $$anonymous$$aximo routines). What I can't get to work is that when the local player command to switch on the flashlight is executed (as I said previously it works as the local player sees the flashlight) the same action on the RemotePlayer Prefab occurs so that everyone else can see it. Do I need to write a script to send the command to the remote player or perhaps have a script on the remote player prefab that watches for the state of the local player flashlight? If so what's the best way of accomplishing this in Unity?

avatar image syclamoth · Feb 28, 2012 at 01:49 AM 0
Share

Yes, you need to manually script it either way. It won't automatically watch the state of all public variables- you need to set that up with OnSerializeNetworkView.

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

6 People are following this question.

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

Related Questions

Unity networking tutorial? 6 Answers

Is server the sender of RPC? 0 Answers

NetworkView NPC's y values are wrong 1 Answer

What is the best way to properly implement shooting over a network? 1 Answer

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