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 LolTroll96 · Jun 17, 2015 at 07:37 PM · multiplayerunity5

10 errors, need help with my script

I have a code for multiplayer using Photon PUN, but I get ten errors. Can someone help me and/or tell me what's wrong with my code?

Here is my code:

 using UnityEngine;
 using System.Collections;
 
 public class Multiplayer : Photon.MonoBehaviour {
     public GameObject myCamera;
     // Use this for initialization
     void Start () {
         if(photonView.isMine){
             myCamera.SetActive(true);
             GetComponent<Drivetrain>().enabled = true;
             GetComponent<CarController>().enabled = true;
             GetComponent<Rigidbody>().useGravity = true;
             AntiRollBar[] AntiRollBar = GetComponents<AntiRollBar>();
             foreach(AntiRollBar bar in AntiRollBar)bar.enabled = false;
         }
         else{
             myCamera.SetActive(false);
             GetComponent<Drivetrain>().enabled = false;
             GetComponent<CarController>().enabled = false;
             GetComponent<Rigidbody>().useGravity = false;
         }
         void OnPhotonSerializeView(PhotonStream Stream, PhotonMessageInfo info){
             if(stream.isWriting){
                 stream.SendNext(transform.position);
                 stream.SendNext(transform.rotation);
             }
             else{
                 transfrom.position = (Vector3)Stream.RecieveNext();
                 transfrom.rotation = (Quaternion)Stream.RecieveNext();
             }
         }
     }
 } 

Here are my errors:

  1. Assets/Photon Unity Networking/Multiplayer.cs(22,42): error CS1547: Keyword void' cannot be used in this context 2. Assets/Photon Unity Networking/Multiplayer.cs(22,43): error CS1525: Unexpected symbol (', expecting )', ,', ;', [', or =' 3. Assets/Photon Unity Networking/Multiplayer.cs(27,28): error CS1519: Unexpected symbol else' in class, struct, or interface member declaration

  2. Assets/Photon Unity Networking/Multiplayer.cs(28,52): error CS1519: Unexpected symbol =' in class, struct, or interface member declaration 5. Assets/Photon Unity Networking/Multiplayer.cs(28,62): error CS1519: Unexpected symbol )' in class, struct, or interface member declaration

  3. Assets/Photon Unity Networking/Multiplayer.cs(28,81): error CS1519: Unexpected symbol (' in class, struct, or interface member declaration 7. Assets/Photon Unity Networking/Multiplayer.cs(29,52): error CS1519: Unexpected symbol =' in class, struct, or interface member declaration

  4. Assets/Photon Unity Networking/Multiplayer.cs(29,65): error CS1519: Unexpected symbol )' in class, struct, or interface member declaration 9. Assets/Photon Unity Networking/Multiplayer.cs(29,84): error CS1519: Unexpected symbol (' in class, struct, or interface member declaration

  5. Assets/Photon Unity Networking/Multiplayer.cs(31,17): error CS8025: Parsing error

Comment
Add comment · Show 3
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 Dave-Carlile · Jun 17, 2015 at 07:42 PM 0
Share

That's.... that's only 5 errors. ;)

avatar image Dave-Carlile · Jun 17, 2015 at 08:33 PM 0
Share

It literally lists only numbers from 1-5. :) But yeah, if I edit the question I can see all 10. $$anonymous$$ust be a Unity Answers display bug.

avatar image LolTroll96 · Jun 17, 2015 at 08:36 PM 0
Share

Probably. xD

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Graham-Dunnett · Jun 17, 2015 at 07:39 PM

You have included your OnPhotonSerializeView() function inside Start(). Move the brace from line 32 to between 21 and 22. (From looking at the code.)

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 LolTroll96 · Jun 17, 2015 at 08:28 PM 0
Share

That removed 3 errors. But... what about the others?

avatar image LolTroll96 · Jun 17, 2015 at 08:35 PM 0
Share

Thanks, I found a typo and now I'm down to 5 errors.

 using UnityEngine;
 using System.Collections;
 
 public class $$anonymous$$ultiplayer : Photon.$$anonymous$$onoBehaviour {
     public GameObject myCamera;
     // Use this for initialization
     void Start () {
         if(photonView.is$$anonymous$$ine){
             myCamera.SetActive(true);
             GetComponent<Drivetrain>().enabled = true;
             GetComponent<CarController>().enabled = true;
             GetComponent<Rigidbody>().useGravity = true;
             AntiRollBar[] AntiRollBar = GetComponents<AntiRollBar>();
             foreach(AntiRollBar bar in AntiRollBar)bar.enabled = false;
         }
         else{
             myCamera.SetActive(false);
             GetComponent<Drivetrain>().enabled = false;
             GetComponent<CarController>().enabled = false;
             GetComponent<Rigidbody>().useGravity = false;
         }
     }
         void OnPhotonSerializeView(PhotonStream Stream, Photon$$anonymous$$essageInfo info){
             if(stream.isWriting){
                 stream.SendNext(transform.position);
                 stream.SendNext(transform.rotation);
             }
             else{
                 transform.position = (Vector3)Stream.RecieveNext();
                 transform.rotation = (Quaternion)Stream.RecieveNext();
             }
         }
 }

Here they are:

  1. Assets/Photon Unity Networking/$$anonymous$$ultiplayer.cs(24,28): error CS0103: The name stream' does not exist in the current context 2. Assets/Photon Unity Networking/$$anonymous$$ultiplayer.cs(25,33): error CS0103: The name stream' does not exist in the current context

  2. Assets/Photon Unity Networking/$$anonymous$$ultiplayer.cs(26,33): error CS0103: The name stream' does not exist in the current context 4. Assets/Photon Unity Networking/$$anonymous$$ultiplayer.cs(29,70): error CS1061: Type PhotonStream' does not contain a definition for RecieveNext' and no extension method RecieveNext' of type PhotonStream' could be found (are you missing a using directive or an assembly reference?) 5. Assets/Photon Unity Networking/$$anonymous$$ultiplayer.cs(30,73): error CS1061: Type PhotonStream' does not contain a definition for RecieveNext' and no extension method RecieveNext' of type `PhotonStream' could be found (are you missing a using directive or an assembly reference?)

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

Character Selection Screen for Multiplayer - C# 1 Answer

[UNET] PlayerPrefab successfully spawns on Server, but Clients only see their own playerPrefab. 0 Answers

[Networking]How to call a command function from a UI element(a button) 2 Answers

How to select a specific network player - photon unity networking 3 Answers

How to synchronize disable and enabling game objects over the network? 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