• 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 DarkerColt · Jul 29, 2012 at 02:30 AM · errorparsingneed

Parsing Error:

I just started creating an online unity game, but i only started using unity a week ago. So i am unsure of how to fix this parsing error Number 1:(2,10), Number 2:(2,32)

function OnNetworkInstantiate1 (msg : NetworkMessageInfo) {

var Camera1 =camera;

if(networkView.isMine == true) { camera.enabled = true; Camera1.enabled = true; } else

{ Camera1.enabled = false; camera.enabled = false; }

}

if anybody could help it would be much appreciated!

Comment
Add comment · Show 2
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 Seth-Bergman · Jul 29, 2012 at 03:17 AM 0
Share

don't know much about networking, but is camera defined somewhere in your script?

at any rate, if Camera1 = camera, then you set them both to reference the same object, so saying

camera.enabled = true;

Camera1.enabled = true;

is repetitive

avatar image OperationDogBird · Jul 29, 2012 at 05:21 AM 0
Share

it looks like you reference the same camera twice..so theres no need to turn both on or both off, or even store the camera in a variable. Just say camera.enabled=true; and camera.enabled=false; respectively.

What is line 2 of this script?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Seth-Bergman · Jul 29, 2012 at 05:41 AM

I think camera is not defined. Try:

 function OnNetworkInstantiate1 (msg : NetworkMessageInfo) {
 if(networkView.isMine) 
 Camera.main.enabled = true;  
 else
 Camera.main.enabled = false; 
 }

but I'm not really sure what you're trying to do though

EDIT: nevermind try

function OnNetworkInstantiate (msg : NetworkMessageInfo) {

lose the 1

if this IS attached to the camera, you can replace Camera.main.enabled with camera.enabled and the above is still good (and now that I think about it, that must be what you want, to enable the camera on OUR player, so use camera.enabled)

 function OnNetworkInstantiate (msg : NetworkMessageInfo) {
 if(networkView.isMine) 
 camera.enabled = true;  
 else
 camera.enabled = false; 
 }
Comment
Add comment · Show 4 · 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 OperationDogBird · Jul 29, 2012 at 05:48 AM 0
Share

my guess is he is using the default call to camera if this script is attached to a Camera.

//On A Camera

 camera.enabled=false;

Just tested and it works.

I havent done a network project, but my guess is its the same deal. $$anonymous$$y guess is the parse error comes from a different line because if the camera is not defined you get

There is no 'Camera' attached to the "GameObject" game object, but a script is trying to access it.

avatar image Seth-Bergman · Jul 29, 2012 at 05:53 AM 0
Share

or this script isn't attached to the camera..

hence my suggestion

but I guess if those are the lines of the error

(2,10),(2,32)

then that really wouldn't add up

more likely it's the first line

function OnNetworkInstantiate1 (msg : Network$$anonymous$$essageInfo) {

I guess...

avatar image Seth-Bergman · Jul 29, 2012 at 05:57 AM 0
Share

yup it's OnNetworkInstantiate, no 1, that's the prob probably

avatar image OperationDogBird · Jul 29, 2012 at 06:01 AM 0
Share

lol yep that would cause the problem! kinda overlooked that 1...

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

How do I fix this really wierd parsing error? 0 Answers

help my code has error CS8205 :parsing error how can I fix? 2 Answers

Getting errors on my chart script 1 Answer

Parsing error and unexpected symbol `}' (25,41) 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges