Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 pea · Aug 10, 2015 at 06:13 AM · particle collisiononparticlecollision

Collision on zero-velocity particle

This one has me stumped a little. I've figured out that in order to use .OnParticleCollision() your particles need to have some velocity.

The problem with that is that I'm trying to make stationary coin pickups. I don't want to give them velocity as then they start moving.

Does this mean that I can't use particle collisions in this case?

One possible - but ugly - avenue of thought is to counter the particle velocity by moving its parent in the opposite direction at exactly the same speed as the particles, thus giving the illusion that they're not moving. I'd rather not do that though.

Any and all insights much appreciated! :)

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 allenallenallen · Aug 10, 2015 at 06:14 AM

Pretty sure OnParticleCollision() doesn't require velocity. Where did you get that information?

Comment
Add comment · Show 6 · 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 pea · Aug 10, 2015 at 07:47 AM 0
Share

I read it somewhere and can't find it now. Will keep looking.

$$anonymous$$y setup is a particle system inside a parent. The parent is moving by setting its position, not using physics (which makes the particles move with it). $$anonymous$$y collision detector also doesn't move.

If I set the velocity of the particles to Vector3.zero I register no collisions. If I set the velocity to Vector3(0,0,-0.01) I get collisions.

I could set up a little proof-of-concept scene if it helps?

avatar image allenallenallen · Aug 10, 2015 at 07:52 AM 0
Share

Yeah, a screenshot of the scene would be nice.

avatar image allenallenallen · Aug 10, 2015 at 08:46 AM 1
Share

After testing OnParticleCollision() myself, I can't replicate your problem. It works fine on my end. And I didn't add any velocity whatsoever.

I made two cubes, one with particle system as child. I moved the parent cube closer to the other cube and got log Particle Hit.

alt text

avatar image pea · Aug 10, 2015 at 09:02 AM 0
Share

Okay, I've made a scene to illustrate. Definitely doesn't work for me. Do you have the "Start speed" set to 0 and also no extra velocity added to particles otherwise? I.e. a stationary particle.

With velocity added collisions get logged:

with velocity

Without velocity no collisions get logged:

without velocity

Here's the Unity project if anyone wants to have a look. To make the collisions work you can simply tick "Velocity over lifetime" and it'll start working.

particleCollision.zip (856 $$anonymous$$B)

screen-shot-2015-08-10-at-85341-pm.png (316.2 kB)
screen-shot-2015-08-10-at-85424-pm.png (340.2 kB)
avatar image allenallenallen · Aug 10, 2015 at 09:13 AM 1
Share

Ah, I see what you meant. I thought you meant external velocity.

You see, a particle system only works when the particles are actually moving using the Particle System component. If you're just spawning random particles in midair without it moving, then it's not behaving like one.

So yes, you do need some sort of INTERNAL velocity/movement/acceleration for the particles to detect collision.

Show more comments
avatar image
1

Answer by pea · Aug 10, 2015 at 09:53 AM

Seeing how particles need some internal velocity to act as a particle I've decided to try the following approach. It gives particles minimal velocity and reverses the velocity every 0.5 seconds. This makes the particles seem like they're stationary. But in actual fact they're ever so slowly moving in alternate directions. And this makes collision detection work.

This script goes on the game object that contains the particle system. I'm not too sure about the performance overhead of this! But I tried to minimise overhead by only updating every 0.5 seconds.

 using UnityEngine;
 using System.Collections;
 
 public class particleVelocity : MonoBehaviour {
 
     private ParticleSystem s;
     private ParticleSystem.Particle[] parts;
     private Vector3 velocity = new Vector3(0,0,0.01f);
 
     void Start() {
 
         this.s = GetComponent<ParticleSystem>();
         InvokeRepeating("updateVelocity", 0, 0.5f);
 
     }
 
     private void updateVelocity() {
 
         this.velocity = -this.velocity;
     
         this.parts = new ParticleSystem.Particle[this.s.particleCount+1];
         int l = this.s.GetParticles(this.parts);
         int i = 0;
         while (i < l) {
             this.parts[i].velocity = this.velocity;
             i++;
         }
         
         this.s.SetParticles(this.parts, l);  
 
     }
 }
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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Why can't I add non-prefab colliders to a particle effects triggers list? 0 Answers

Shuriken collision with terrain? 0 Answers

Getting the position/intersection of collided particles 1 Answer

Getting particles from the same system to act differently with different objects? 0 Answers

Collide with Non-Moving Particle 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