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 user5200 · Jun 08, 2012 at 03:27 AM · prefabplayerparticlesystemfollow player

Particle system that follows player and turns on or off

Hello all,

I am trying to get some particle effects on the main character of my game. There are 2 different ways that I have tried this and I have run into problems with both. Perhaps someone can help me come up with a better method or improve one of my existing ones?

What I'm trying to do is quite simply actually. Whenever I press a button, particles should emit from the player's body, but here's the catch: they should follow him when he moves. Here are the two ways I have tried, and the problems with each one:

  1. Attach a particle system prefab as a child to the player.

After I have attached it to the player, I do not know how i can get it to "turn on" or "turn off" in the scripts. I have tried using:

 sprayer.particleEmitter.particleSystem.Play(); 

But this results in an error that says that I do not have a particle emitter attached. I don't know how I am supposed to access the particle system otherwise because although I have declared sprayer as a particle system, intellisense does not give me any options that have to do with the particlesystem.

  1. Simply instantiate the particle system at the player's position.

The reason that this fails is because the particle system stays in the place that it was instantiated. I have tried attaching a script to the system that sets its position to the player's transform.position. But this does not work because prefabs cannot reference an object that is inside the scene already.

Recently, I am also getting an error similar to this one: http://answers.unity3d.com/questions/238274/updateparticle-system-should-not-happen-on-disable.html

Any other advice on playing around with particle systems would be greatly appreciated. Thanks in advance!

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
1
Best Answer

Answer by drizztmainsword · Jun 08, 2012 at 04:22 AM

So when Unity update to 3.5, they implemented a new particle system (Shuriken). The new particle system is used with the ParticleSystem component. ParticleEmitter is part of the old particle system.

If you have a Particle System component on your "sprayer" object, you're going to need a few variables.

First, you're going to want a variable (type of ParticleSystem) for the particle system, which you can assign in the editor by dragging the system into the appropriate place or you can grab in code using the GetComponent() function.

Then, once you have that variable, you should be able to call the Play() and Stop() functions normally, and intellisense should be able to see them.

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 user5200 · Jun 08, 2012 at 07:53 PM 0
Share

Thanks very much for the info. This has solved my problem with ease!

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

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

Player spawn after touching 0 Answers

[Networking] Player prefab in a Hearthstone-like card game 0 Answers

Static target in the srcipt for my Prefab 2 Answers

Problem when assigning a prefab 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