Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Dryden Richardson · Sep 01, 2011 at 11:56 PM · javascripterrorbce0005bce0034

Need some help with my Gravity Gun, New to Scripting.

Hi, I'm having trouble with static variables, I dont know why because I think I'm doing it right, maybe it's not the way I wrote the Variable, maybe it's the way the first code it written which two people helped me with. I'm trying to create a Gravity Gun, so I have a Standby script which is placed on the Gun it's self, then I have an Object script, the object script makes whatever it's attached to follow the reticule on the gravity gun.

Here's the Error I'm receiving BCE0005: Unknown identifier: 'Activate'.

 if(Activate==true){
     //do something
 }

This is in the Object Script right before the function Update.

 static var Activate = false;

This is in the Standby Script at the top.

Here's what I'm trying to achieve, the Static var is what's used to activate the function command inside the object script so it activates the script and it will follow the Gravity Gun's reticule, the Static var is inside the Standby Script it is set to "false" as default, then it gets changedwhen I press the Left Mouse Button, it's Supposed to change to static var Activate = true;

Here's the standby script.

 static var Activate = false;
 
 function Update () {
 }
 
 if( Input.GetButtonDown("Fire1"))
 {

//I'm also thinking about what I need to put here as It wont allow me to use the Variable inside here, I've tried (Activate==true); but I get the Error BCE0034: Expressions in statements must only be executed for their side-effects.

 }
 

Please dont redo the Entire code, I dont want to go through all the hassle, I just want to help me sort out these errors. I'm getting used to scripting, I'm learning where to put lines of codes now, I just need a bit more practice before I can consider myself "Good" at programming. Please read and go over everything, I'll post both scripts if nessasary. Thanks for reading and contribution.

Comment
Add comment · Show 4
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 DayyanSisson · Sep 02, 2011 at 12:01 AM 0
Share

Explain exactly what a gravity gun is, because some people might not know that. Is it a gun that increases gravity of it's target, or what?

avatar image Waz · Sep 02, 2011 at 01:11 AM 2
Share

You need to pull back from the problems - these things are not solved by trying to look at individual lines and individual error messages. A compiler gets to think like that, but you as a programmer have to understand the root cause of the error, which may have resulted from a mistake somewhere else entirely. When you program, you must understand the entirety of what you have written and why it should function in the way you anticipate. All the compiler can do is tell you when it cannot understand you, but you then have to go and fix your code, be the change some little syntax error on the specified line, or a semantic error that could be anywhere related to that line.

Currently, you do not understand your "own" code, and so you cannot understand the compiler's complaints.

You must go back and understand your code, otherwise you're just getting other people to write code for you, which will never get you to being any sort of programmer, good or otherwise.

avatar image Dryden Richardson · Sep 02, 2011 at 07:58 PM 0
Share

Sorry nighthawx349, I dont know why I didn't explain it, It's a gun that can manipulate Physical Objects.

avatar image Dryden Richardson · Sep 02, 2011 at 07:59 PM 1
Share

Thanks Warwick Allision, You made me understand how the Compiler works.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by aldonaletto · Sep 02, 2011 at 01:59 AM

Man, your question is really confusing! What I understood from your question is that you want to set the variable Activate to true when the mouse left button is pressed, and this variable will be used in other scripts. Supposing I'm right, the Standby.js script should be something like this:

static var Activate = false;

function Update(){ if (Input.GetButtonDown("Fire1")){ Activate = true; } } Since Activate is static, you can access it in other scripts as Standby.Activate:

if (Standby.Activate){ // you don't need to compare a boolean to true
    // do something
}
Comment
Add comment · Show 1 · 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 Dryden Richardson · Sep 02, 2011 at 07:57 PM 0
Share

Thanks, This Helped alot, I know know how to use Variables with If statements :)

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

7 People are following this question.

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

Related Questions

List in JS, Unknown indentifier 3 Answers

BCE0005 Unknown identifier issue 1 Answer

shooting script error (java) 2 Answers

Exception error 1 Answer

Trouble converting player controller from JS to C# 1 Answer


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