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 rohan bhangui · Oct 04, 2011 at 01:19 AM · errorparticleemittergetbutton

error in a script for jet pack for plane

So im trying to get a "boost" particle effect working for a fighter. Now ive looked at the scripting reference and i have not been able to figure this one out. Can anyone help me

 > function Update () {     if
 > (Input.GetButton ("Fire1") {
 >         particleEmitter.emit = true;     }
 >     particleEmitter.emit = false;          }

Error Console Message:

Assets/afterburner effect.js(3,39): BCE0044: expecting ), found '{'.

Assets/afterburner effect.js(8,1): BCE0044: expecting EOF, found '}'.

The importer for asset Assets/afterburner scirpt.js (MonoImporter) did not generate a MD4 digest. (i didnt get this last message)

can anyone help me understand this

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by syclamoth · Oct 04, 2011 at 01:59 AM

There are multiple issues here-

1. You don't have enough brackets!

In your if statement, you need to close off the condition properly!

if(Input.GetButton ("Fire1")) {
    // do stuff
}

2. Even if it worked, you would immediately turn it back off again!

When you write an if statement, it executes the bits inside the curly brackets only in the case where the condition returns true. However, as soon as you get out of those brackets, it always executes the next bit! You should be using an 'else' statement, afterwards--

if(Input.GetButton ("Fire1")) {
    particleEmitter.emit = true;
} else {
    particleEmitter.emit = false;
}

That way, it only disables the particles if you aren't holding the fire button.

Give that a shot!

Comment
Add comment · Show 3 · 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 rohan bhangui · Oct 04, 2011 at 03:20 AM 0
Share

that helps it works perfectly thx for solution

avatar image Bunny83 · Oct 04, 2011 at 03:24 AM 0
Share

@rohan bhangui: ins$$anonymous$$d of posting a comment as answer you could upvote this answer and if it solves your problems mark it as "the right answer".

btw: such simple boolean statements can also be written as:

 particleEmitter.emit = Input.GetButton ("Fire1");
avatar image syclamoth · Oct 04, 2011 at 07:02 AM 0
Share

@Bunny83 Oh yeah, forgot about that- for something as simple as this, that'd be perfect!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Particle Emitter error, Missing reference exception. 1 Answer

Casting error on multiple emitters 3 Answers

How to enable a ParticleEmitter in scripting 2 Answers

How to fade out an object with no renderer (and how is that even possible?!) -1 Answers

I keep floating when i want gravity and I have some code can you guys help me please 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