Search Unity

Particle attractor (or Particle system attraction)

Discussion in 'Scripting' started by briosh, Dec 25, 2010.

  1. briosh

    briosh

    Joined:
    Aug 9, 2010
    Posts:
    17
    Has anyone done something like this?
    The idea is 'simple': a particle emitter emits particles that get 'attracted' ('sucked') by an other object.

    I found various threads that disqus the subject to no result...

    Since there isn't any kind of 'attractor' object i suppose this can only be done by coding. Maybe changing the x,z,y force depending on the target object position or something....

    I am not an experience programmer but if i have any progress with this i will post!
     
  2. briosh

    briosh

    Joined:
    Aug 9, 2010
    Posts:
    17
    I might have a workarround for now.... Just tried it and works for what i want to do:

    1. Create the particle system and
    2. set local X velocity to 5 (or whatever you want)
    3. attach the particle system on a transform and set its rotation to 270 (this may vary depending on the local velocity you use)
    4. set that transform to follow the player (or the object that will 'emit' the particles) with the built-in 'Follow Transform' script.
    5. set that trasnform to lookAt the object that will 'attract' the particles and....

    thats it! The object looks like it attracts the particles. And if you mesh arround a bit with distances and emittion ammounts, you can get more realistic results.

    Only problem is that this won't convince anyone if you use complex mesh particle emitters.

    Actually it is usefull only if you want to do what i wanted: to make an object 'charge' with particles an other....

    I hope it helps though....
     
    ChinhNguyenDaiVuong likes this.