Particle explosion direction

ejaaskel posted this 22 November 2015


I'm trying to create a game with planes. When my plane crashes to the ground I'd like it to "break apart" naturally when it hits the ground.

Basically what I've tried so far is that when plane collides I call Destruct with speed zero. This places the voxels nicely on the ground, which doesn't look too good when the plane crashes on the ground full speed. On the other hand, if I set any speed, it seems like the voxels fly to wrong direction (90 degrees off, to the left). How can I control the shape and direction of the emission properly? Should I edit the "PicaVoxel Particle System" object or the plane itself? Editing the shape in the PicaVoxel Particle System doesn't seem to do much

Order By: Standard | Newest | Votes
ejaaskel posted this 22 November 2015

Okay, so I guess I've sorted (at least part of) the problem. The weird behaviour where the explosion always flew particles to left was because of some weird offsets I had done because I hadn't set the pivot to the center. More help on this matter is appreciated. Especially if it is possible to do the breaking apart (voxels getting detached from one another) as I mentioned.

GarethIW posted this 23 November 2015


So, as you've discovered, the centre of explosion for the destruct method is the transform.position of the volume, with the volume's Pivot taken into account. You can see the algorithm used for the particle velocity at the end of Volume.Destruct (Volume.cs line 543):

pos => (pos - transform.position).normalized * Random.Range(0f, particleVelocity * 2f));

This delegate is called for every one of the voxels in the volume when spawning a particle for destruction. pos is the position in worldspace of the particle. The first part gets a normalised direction vector in the opposite direction of the volume's transform. The second part gives the particle a random amount of velocity in that direction.

If you wanted to start playing with how the particles are spawned, you could make a copy of the Destruct method (PlaneDestruct or something), and then you can play with that algorithm for yourself.

As for what would look natural for a plane breaking apart, I can't really tell you as that's subjective. If you could describe the result you want along with a video of what you currently have then I could make some suggestions.

Our 127 members have posted 466 times in 112 discussions