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 /
This question was closed Oct 23, 2013 at 02:34 AM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by R1pnd1p · Oct 18, 2013 at 02:43 AM · particlesystemrendererdisableenable

am i doing this right? (renderer enable/disable)

 using UnityEngine;
 using System.Collections;
 
 public class flamebreath : MonoBehaviour {
 
     // Use this for initialization
     void Start () {
         particleSystem.renderer.enabled = false;
     
     }
     
     // Update is called once per frame
     void Update () {
         if (Input.GetKeyDown (KeyCode.F)){
             particleSystem.renderer.enabled = true;
         }
         if (Input.GetKeyDown (KeyCode.F)){
             particleSystem.renderer.enabled = false;
         }
     
     }
 }


when i press play, the renderer on the particle effect is off, but when i press "F" it doesent turn on.

i removed the line of code in "start" and yes, the fire does spawn, but when i press "F" it disables and doesent turn back on. thanks in advanced!

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

  • Sort: 
avatar image
0
Best Answer

Answer by LukaKotar · Oct 18, 2013 at 02:47 AM

You are setting it to true, then back to false. Both if statements will execute.

 if (Input.GetKeyDown (KeyCode.F)){
     //The line below will set enabled to the opposite value:
     particleSystem.renderer.enabled = !particleSystem.renderer.enabled;
 }
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 R1pnd1p · Oct 18, 2013 at 06:02 AM 0
Share
 void Start () {
         particleSystem.renderer.enabled = !particleSystem.renderer.enabled;
     
     }
     
     // Update is called once per frame
     void Update () {
         if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.F)){
             particleSystem.renderer.enabled = true;
         }
         if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.F)){
             particleSystem.renderer.enabled = !particleSystem.renderer.enabled;
         }
     
     }
 }


this is the changes i made, its still not enabling the renderer, it stays off.

avatar image R1pnd1p · Oct 18, 2013 at 06:04 AM 0
Share

omg im such a noob, thanks bro.

avatar image LukaKotar · Oct 18, 2013 at 06:05 AM 0
Share

Delete the first if statement.

This should work:

 void Start () {
     particleSystem.renderer.enabled = false;
 }
 
 void Update () {
     if (Input.GetButtonDown ($$anonymous$$eyCode.F)){
         particleSystem.renderer.enabled = !particleSystem.renderer.enabled;
     }
 }

Follow this Question

Answers Answers and Comments

15 People are following this question.

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

Related Questions

Is there any command that can reference deactivated objects? 1 Answer

Fade an object in and out 0 Answers

Enable/Disable CharMotor jumping 1 Answer

Disable/Enable Buttons and Text plz help jc 1 Answer

Can't enable/disable canvas on Android device 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