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
-3
Question by BSVALVE · Apr 21, 2011 at 10:50 AM · syntax-errorbce0044

HELP ME PLEASE!----------------------------!?

// Script that puts a window on-screen where the player can toggle who he controls // It works by sending SetControllable messages to turn the different characters on and off. // It also changes who the CameraScrolling scripts looks at.

// An internal reference to the attached CameraScrolling script private var cameraScrolling : CameraScrolling; // Who is the player controlling private var selected = 0;

var PatriotTagName: String = "Patriot"; // List of objects to control //var targets : Transform[]=FindObjectsOfType(Transform) as Transform[]; var targets : Transform[];// = new Transform[1]; //var convertedTargets : Array = new Array(targets); // What to display on the buttons in the window var targetButtonNames : String[]; //var target:Rigidbody; ///////////////////////////////////////////////////////////////////////////////////////// //var target:Transform;

// On start up, we send the SetControllable () message to turn the different players on and off. function Awake () { //targets = GameObject.FindWithTag("Patriot").transform; ///////////////////////////////////////////////////////////////////////////////////////////// // Get the reference to our CameraScrolling script attached to this camera; cameraScrolling = GetComponent (CameraScrolling);

 // Set the scrolling camera's target to be our character at the start.
 cameraScrolling.SetTarget (targets[0], true);

 // tell all targets (except the first one) to switch off.
 for (var i=0; i < convertedTargets.length; i++) 

     targets[i].gameObject.SendMessage ("SetControllable", (i == 0), SendMessageOptions.DontRequireReceiver);

}

function Update(){ //targets = transform.FindGameObjectsWithTag("Patriot");

 var thePatriot: GameObject = gameObject.FindGameObjectsWithTag(PatriotTagName);

 if (thePatriot == null){
     return ;
 }       
 else{
     targets = thePatriot.transform;
 }   
 /*var PatriotPrefab = transform.gameObject.Find("Patriot");

 for ( var target:GameObject in PatriotPrefab){
     cameraScrolling.SetTarget (targets[1]);
 }

}*/

private var windowRect : Rect = Rect (20, 20, 250, 40); // Make the onscreen GUI to let the player switch control between Lerpz and the spaceship. function OnGUI() { //Debug.Log(DoControlsWindow); // Make a popup window windowRect = GUILayout.Window (0, windowRect, DoControlsWindow, "Camera Controls");

 // The window can be dragged around by the users - make sure that it doesn't go offscreen.
 windowRect.x = Mathf.Clamp (windowRect.x, 0.0, Screen.width - windowRect.width);
 windowRect.y = Mathf.Clamp (windowRect.y, 78.0, Screen.height - windowRect.height);

}

// Make the contents of the window function DoControlsWindow (windowID : int) { // Make the window be draggable in the top 20 pixels. GUI.DragWindow (Rect (0,0, System.Decimal.MaxValue, 20));

 GUILayout.Label ("Press to changes target.");

 // Let the player select the character
 selected = GUILayout.Toolbar (selected, targetButtonNames);

 // If the user has selected a new character, we'll send new SetControllable messages to turn on the other character. 
 // Then we'll change who the CameraScrolling script is tracking.
 if (GUI.changed && targets[selected] != cameraScrolling.GetTarget ()) {
     targets[selected].gameObject.SendMessage ("SetControllable", true, SendMessageOptions.DontRequireReceiver);
     cameraScrolling.GetTarget().gameObject.SendMessage ("SetControllable", false, SendMessageOptions.DontRequireReceiver);
     cameraScrolling.SetTarget (targets[selected]);
 }

 // Show a different instruction label depending on what was selected above.
 switch (selected) {
     case 0:
         GUILayout.Label ("Player");

     break;
     case 1:
         GUILayout.Label ("Player's Dog.");

     break;
     case 2:
         GUILayout.Label ("Enemy to Kill.");

     break;
 }

}

// Ensure there is a CameraScrolling script attached to the same GameObject, as this script // relies on it.


Assets/Camera/CameraFocus.js(56,1): BCE0044: expecting }, found 'private'.

This script left above line to me which turn me confused for what should I do any Unities please HELP ME!

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 Bunny83 · Apr 21, 2011 at 11:06 AM 1
Share

Fix your titel. That's not a question!!! Questions normally ends with a question-mark!

1 Reply

· Add your reply
  • Sort: 
avatar image
5

Answer by FrHaYwOrKs · Apr 21, 2011 at 10:55 AM

From line 49 to line 54 you have:

/*var PatriotPrefab = transform.gameObject.Find("Patriot");

 for ( var target:GameObject in PatriotPrefab){
     cameraScrolling.SetTarget (targets[1]);
 }

}*/

You have commented a } that should be left uncommented, change that block of code to:

/*var PatriotPrefab = transform.gameObject.Find("Patriot");

 for ( var target:GameObject in PatriotPrefab){
     cameraScrolling.SetTarget (targets[1]);
 }*/

}

And it should work fine...

Comment
Add comment · Show 8 · 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 BSVALVE · Apr 21, 2011 at 11:08 AM 0
Share

Thanks u r right but this script still saying it cannot convert transform to transform[] what could I do, any ideas?

avatar image FrHaYwOrKs · Apr 21, 2011 at 11:14 AM 1
Share

The script is right since in line 13 you are declearing var "targets : Transform[];// = new Transform[1];" so targets is of type Trasform[] and then in line 47 you state "targets = thePatriot.transform;" and thePatriot.transform is of type transform, so you are trying to assign a transform to a Transform[]. I haven't exa$$anonymous$$ated the script meaning at a logical level, just found out the current errors, the solution depends on what you need to do with that script! ^^

avatar image BSVALVE · Apr 21, 2011 at 11:29 AM 0
Share

I were wanted to add the re-instantiation objects back to that position for it's transform[] but trying this out is hard.

avatar image FrHaYwOrKs · Apr 21, 2011 at 01:20 PM 0
Share

The problem is that your "targets" variable is a list, so you cannot assign a single transform object to a list-of-transforms object. Try to assign you "thePatriot.transform" as an element of a list, ins$$anonymous$$d of assigning it to the whole list!

avatar image BSVALVE · Apr 21, 2011 at 01:30 PM 0
Share

Could you please write an example for me I am sorry English wasn't my first language.. I do not understand what you mean by "as an element of a list".. ( even I could know the language but I might not know how could it be for Unity javascript so please Help me.)

Show more comments

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

No one has followed this question yet.

Related Questions

Code Not Working. Any Ideas? 2 Answers

Script error. Please Help! 4 Answers

BCE0044: expecting ':' found ';' 1 Answer

Basic on collision play animation code not working 1 Answer

BCE0044: expecting :, found '=' 3 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