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 /
  • Help Room /
avatar image
0
Question by ChrisSch · Oct 18, 2015 at 09:09 AM · collisionparentchildparticle systemonparticlecollision

OnParticleCollision() on parent script, for a child particle system?

I'm working on a turret asset script update, and trying to add a particle turret to the list of features.

I have the script on the parent, and a child game object with the particle system. I put OnParticleCollision() in the parent script, but its not detecting collision of the particle system, because its on a child gameobject.

It only works if I place the script with OnParticleCollision() on the gameobject with the particle system, doesn't work if its a on a parent. I assumed it would work, because that's how regular compound colliders work.

The turret script has to be on the parent, and the particle collider will in most cases have to be on a child. And for simplicity's sake, I'd prefer to avoid splitting the script into two pieces just so I can have a few lines of code about particle collision, somewhere down the hierarchy on one of the child gameobjects. So can this be done somehow? Keeping the script on the parent, and detecting collisions of the child particle system?

PS. Alternatively maybe being able to adjust the particle start position through script would be good too, then the particle system won't have to be on the child game object, but I don't see that option in the documentation.

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 ChrisSch · Oct 18, 2015 at 06:53 PM 0
Share

Anyone?

Basically all I want to know is, does OnParticleCollision have to be on the game object with the particle system? Can it be on the parent of that game object somehow?

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by allenallenallen · Oct 19, 2015 at 03:57 PM

I don't believe there's a workaround without splitting the work between the parent and child objects.

Each OnParticleCollision() is for the collider of that GameObject or the Particle System that script is attached to. So like you suspected, the OnParticleCollision() in the parent will be trying to get collision information for the parent object without caring about its child object.

Is there a reason you want to call OnParticleCollision() on the child object? Can it not be called on the object that the particles will be colliding into?

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 ChrisSch · Oct 19, 2015 at 04:18 PM 0
Share

Yes theres two reasons. One is because there could be multiple particle systems on the same turret, and the other is, they need to be positioned at the tip of the barrel, so they always face where the turret head is facing, and their position to be where the tip is.

But since there's no "particleOrigin" or something variable for it, and the script that handles the entire system is at the root(parent) of the turret, there's no other option than to have a small script of few lines of code on each particle system, that receives and passes on the damage value. I just didn't want the users to go through the hassle of placing that, since all other types (raycast, projectile, melee, shock, laser), and all other aspects of customization are done from the topmost parent, of all the parts.

I think I'll settle for whenever the user adds a particle system to the particles slot, it'll add that script too (through add component), without their need to do it personally.

Thanks for clearing it up. Here's the asset in question. I'll give you both a voucher for trying to help, if you need it. Just tell me where to send. :)

avatar image
0

Answer by iyenal222 · Oct 19, 2015 at 03:17 PM

This can help:

http://docs.unity3d.com/ScriptReference/ParticleSystem.Play.html

Use public void Play(bool withChildren = true); on a parent gameobject to play a child particle system but I have tested it and he give me errors :-(, maybe you have more luck...

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 ChrisSch · Oct 19, 2015 at 03:24 PM 0
Share

No I have no issues playing or anything. Its the particle collision that doesn't work if the script with OnParticleCollision() is on parent, and not the child gameobject with the particle system.

Like this -Parent (with script that contains OnParticleCollision) ->>Child (with the Particle System I'm trying to get collision info from)

Because if it was regular Parent with rigidbody, and child with collider, it would work. But particle collision doesn't work like that I guess? So I have to put a seperate script on the child just to get collision from. :P

I'm wondering if that's how its meant to be, and if there's a workaround for it. :)

avatar image ChrisSch · Oct 19, 2015 at 04:37 PM 0
Share

Hey I can give you a voucher for the asset too, if you need it. For trying to help. Just tell me where to send. :)

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

36 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

Related Questions

Getting Parent object from a child's collision. 1 Answer

player parent is killed when sword child hits enemies 2 Answers

How could I make the children of an object face the direction it is moving on the y-axis? 0 Answers

How can I reattach the player transform after using DetachChildren() to flip the parent? 2 Answers

Calculate child local position within a parent GO without a child, given a world position..? 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