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 Jtrobinson · Jan 06, 2019 at 11:55 PM · script.particlesysteminstatiate

How to instanciate a particle system prefab to a certain moving game objects position?

The obstacles which have coins on them are moving toward the players. When the player collects the coin the coinparticlesystem prefab plays on the coins position before the coin game object is destroyed. The only problem is is that I don't know how to instatiate something on an object that is moving here is my code so far.

alt text

coinposition.png (15.2 kB)
Comment
Add comment · Show 1
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 ifurkend · Jan 07, 2019 at 12:32 AM 0
Share

Since 2018.1 the Particle System (PS) offers the sub emitter spawning condition of “Trigger” so you can attach an empty local PS (use ring buffer mode if you’re using 2018.3), enable Trigger module to Callback on Enter and parent your coin PS to this spawning PS as a Trigger Sub Emitter.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ifurkend · Jan 07, 2019 at 01:36 AM

The setup I mentioned in my comment doesn't require any scripting. You may reference my video. That "SubEmitter0" is supposed to be your coin particle effect. https://www.youtube.com/watch?v=ijWWQoYdc8c

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 Jtrobinson · Jan 07, 2019 at 02:07 AM 0
Share

Thanks man I apreciate it. I'll test it out next time I get on unity and let you know how it goes. Again thanks

EDIT: I did exactly what you did in your video, and it didn't work for me I have know idea what I'm doing wrong. :(

avatar image
0

Answer by Magso · Jan 07, 2019 at 12:27 AM

if this code is on the coin then it's

 Instantiate(CoinParticleSystem, transform.position, Quaternion.identity);

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 Jtrobinson · Jan 07, 2019 at 01:02 AM 0
Share

The objects are instatiated shortly after the game plays, therefore wouldn't I get a null refrence exception if I have the script on a coin that isn't generated yet?

avatar image Magso Jtrobinson · Jan 07, 2019 at 01:17 AM 1
Share

"When the player collects the coin the coinparticlesystem prefab plays on the coins position before the coin game object is destroyed." Led me to believe that the coins we're already in the scene and each of them had a script with the variable CoinParticleSystem assigned to a prefab. If OnTriggerEnter2D is called on a different object before the coins are instantiated and it attempts to find them, that would cause a null reference exception.

avatar image Jtrobinson Magso · Jan 07, 2019 at 02:05 AM 0
Share

Sorry about that, I didn't clarify that very well. I initially did exactly what you said prior thats why I just made a particle system prefab that remains a constant

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

133 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 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 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 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 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 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 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 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 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 their any way to save a particle system when it's not instantiated yet? 2 Answers

How to instantiate an object with scripts? 1 Answer

How to Play ParticleSystem from AnimationEvent? 0 Answers

How to edit particle system size over lifetime curve with script? 0 Answers

Change particle size based on how near it is to a given point or height 2 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