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 Sam 2 · Jul 04, 2010 at 07:35 PM · triggerguitextureparticle

I want to trigger particle with collectable

I want to start particle system on terrain only when the player have collect all 4 collectables in my map, but my script doesn't work.I want it to start from when the guitexture I made was complete with 4 colletables and I made this script to do the job:

function start () {

  if(guiTexture.texture == 4) {
     particleEmitter.emit = true;
     guitexture.enabled = true;
   }
   else if (guiTexture.texture <= 4){
     particleEmitter.emit = false;

}

I dont realy understand what I am doing wrong,if I put this in the wrong place or if a create it in the wrong files, I put em in the particle prefab that i made and have associated with. I am not so good in understanding code, so someone can help me, give me some advice, so I can figure out what I am doing wrong. Thanks for your time.

Sam

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by spinaljack · Jul 04, 2010 at 10:23 PM

If you put a function in start() it'll only ever be executed once.. at the start.

If you want to check every frame if the player has something you do it in Update()

If you wanted to check if the player has 4 or more of something and then start a particle effect you do this:

function Update(){
   if(itemNumber>=4){
       Instantiate(particleEffect,transform.position,transform.rotation);
   } else {
       // don't do anything
   }
}

Where particleEffect is a prefab you made of the particle effect

Comment
Add comment · Show 2 · 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 Sam 2 · Jul 05, 2010 at 12:04 AM 0
Share

I try, but it look like it does'nt work. Do I have to add those line to my script or this new one is complete ??

avatar image spinaljack · Jul 05, 2010 at 12:33 AM 0
Share

you need to change the variables to the ones you're using.

avatar image
0

Answer by Sam 2 · Jul 06, 2010 at 04:32 AM

So, after many headache along the last week-end I finally solve my problem. So here I have the code who work for my project;

static var carte : int = 0;

var carte1tex : Texture2D; var carte2tex : Texture2D; var carte3tex : Texture2D; var carte4tex : Texture2D; var carte0tex : Texture2D;

function Start () { guiTexture.enabled = false; carte = 0; }

function Update () { if (carte == 1) { guiTexture.texture = carte1tex; guiTexture.enabled = true; } else if (carte == 2) { guiTexture.texture = carte2tex; } else if (carte == 3) { guiTexture.texture = carte3tex; } else if (carte >= 4) { guiTexture.texture = carte4tex;

 var flames : GameObject = GameObject.Find("particlegroup");

 var flameEmitter : ParticleEmitter = flames.GetComponent(ParticleEmitter);
 flameEmitter.emit = true;

 var smoke : GameObject = GameObject.Find("particlegroup_b");

 var smokeEmitter : ParticleEmitter = smoke.GetComponent(ParticleEmitter);
 smokeEmitter.emit = true;

 Destroy(GameObject.Find("Map_GUI"));

} else{ guiTexture.texture = carte0tex; }

}

The story was that my code was really off the track. I have create a first script separated of my other script who made me collect my collectible, so this won't work for the particle. Today I ask my teacher for help. He tell me who was a campfire already as an example for the course so we use the part about the campfire who was started by a trigger whit a collectible .match. I delete my old script and I use it in my collectible script and it work well.

So my principles mistakes was:

  1. Creating a new script for my particle only.
  2. Creating a wrong code because I
    don't understand it so well.my bad.
  3. Don't strip the emit case in my
    particle element in the Hierarchy to disabled it.
  4. Have associated my old script in the particle prefab I have create. I don't understand why but the teacher tell me to don't do that because it is not necessary so I erase it.

I don't understand at all the instantiate you have suggest. But thank you for your help spinaljack.

So this is only my collectible script I have made earlier for my collectible only, you can see the difference for yourself and see what I was missing.

static var carte : int = 0;

var carte1tex : Texture2D; var carte2tex : Texture2D; var carte3tex : Texture2D; var carte4tex : Texture2D; var carte0tex : Texture2D;

function Start () { guiTexture.enabled = false; carte = 0; }

function Update () { if (carte == 1) { guiTexture.texture = carte1tex; guiTexture.enabled = true; } else if (carte == 2) { guiTexture.texture = carte2tex; } else if (carte == 3) { guiTexture.texture = carte3tex; } else if (carte >= 4) { guiTexture.texture = carte4tex; Destroy(GameObject.Find("Map_GUI")); } else{ guiTexture.texture = carte0tex; }

}

Lot to learn! hope this help somebody else

note: "particle group" and "particle group_b" is my particle prefab

"Map_GUI" is the group who I put the GUItexture and the collectable script I create for my collectable system earlier.

Thank you everybody

Sam

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

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

Enter Trigger activate Gui Texture 1 Answer

How to fade between 3 GUI textures? 1 Answer

Get all particles within trigger collider? 1 Answer

Show GUI Texture on Trigger and Instantiate Object if Button pressed while In Trigger? 1 Answer

Register Particles going through Trigger collider 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