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
0
Question by marsfan · Jul 19, 2013 at 05:03 PM · gameobjectparticlesdeleted

Why is my code deleting my particle emitter?

I wrote a simple code to check the distance of an object and the camera and then change the emission level of a flame emitter, but after I get a certain distance from it, it automatically deletes the game object that has the emitter and code in it. Attached is the editor area of unity and the code I am using. alt text

 var target: Transform;
 function Update () {
 var dist : float = Vector3.Distance(target.position, transform.position);
     if(dist <= 13){
     particleEmitter.maxEmission = 100;
 }else{
     particleEmitter.maxEmission = 0;
 }
 }
 

edit: think I found a fix. It does not like me to use the number 0, it thinks I just want it deleted, now I need to find a number small enough for it to no longer shoot puffs of flames.

edit: only works temporaly, i changed the code and it still seems to want to happen, if I remove the code it stops having the problem. new code:

 var target: Transform;
 function Update () {
 var fwd = transform.TransformDirection (Vector3.forward);
 var dist : float = Vector3.Distance(target.position, transform.position);
     if(dist <= 13 /*&& !Physics.Raycast (transform.position, fwd*/){
     /*particleEmitter.maxEmission = 100;*/
 }else{
     /*particleEmitter.maxEmission = .0001;*/ 
 }
 }

edit: should be the final one, code is now: var target: Transform; function Update () { //var fwd = transform.TransformDirection (Vector3.forward); var dist = Vector3.Distance(target.position, transform.position);

         if(dist <= 13){
     particleEmitter.emit = true;
 }else{
     particleEmitter.emit = false; 
 }
 }

bug still happens, but if code is changed to:

 var target: Transform;
 function Update () {
 //var fwd = transform.TransformDirection (Vector3.forward);
 var dist = Vector3.Distance(target.position, transform.position);
 
         if(dist <= 13){
     particleEmitter.emit = true;
 }else{
     particleEmitter.emit = ***true***; 
 }
 }

the problem stops

screen shot 2013-07-19 at 10.17.10 am.png (95.0 kB)
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 cdrandin · Jul 19, 2013 at 05:28 PM 0
Share

Are you sure that is the only code referencing your emitter object. Simply that line won't delete the object. Double check any reference your your object to check that something else isn't destroying it. Should still be alive.

avatar image marsfan · Jul 19, 2013 at 06:37 PM 0
Share

there is noting else attached to it, the only other script is just a transform.lookat code. Its gameobject does slide in an animation though. It seems to happen when I move into the 13 unit field and then back out of it. Not sure though.

avatar image marsfan · Jul 19, 2013 at 06:40 PM 0
Share

nope, I cannot find a gameobject.destroy, i will check again though. It is just a standard asset with a added code and a changed parameters.

avatar image marsfan · Jul 19, 2013 at 06:41 PM 0
Share

it actually happens whenever I am more than 13 unity away.

0 Replies

· Add your reply
  • Sort: 

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

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Detect when instance has deleted 0 Answers

Laser Beam in Unity 0 Answers

Resetting non-looping particle system 5 Answers

HELP Find gameObject With tag in another array 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