- Home /
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!
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
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?
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;
}
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.
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...
yup it's OnNetworkInstantiate, no 1, that's the prob probably
lol yep that would cause the problem! kinda overlooked that 1...
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How do I fix this really wierd parsing error? 0 Answers
Getting errors on my chart script 1 Answer
Parsing error and unexpected symbol `}' (25,41) 1 Answer
Compiler error?? 2 Answers