Particle spawn on surface using surface normal
If I have a particle system with two emitters in it, and the first particles colliding with a surface spawn new particles at the hit locations, how do I switch the new particles from facing the camera to facing the surface normal of the hit surface?
Do I have to use Source > Event Generator Type > Blueprint ?
asked Sep 08 '14 at 03:07 AM in Using UE4
Hey Tomofnz -
Well better really late than never, but I finally got time to set down and work on this issue again. It is actually fairly complicated because Rotators are extremely complicated and passing modified values between components can be tricky. That being said here is the Particle System break down which is a fairly easy setup. I have one emitter that functions as a drop and an event generator feeds the spawning of another emitter (Event Receiver) on Collision. This Event Generator allows our Blueprint to read that Hit Location. In the Collision Spawned Emitter, I have an Initial Mesh Rotation (this should work with a normal sprite as well just use Initial Rotation instead of Mesh Rotation) set up with a Vector Particle Parameter which we will set in our Blueprint.
Next the Blueprint, make an actor blueprint with your Particle System like follows:
We Start with the OnParticleCollide Node which registers each collision from that event generator, we take the normal of the point of collision and take a Cross Product of the Impact Normal and the Up Vector Normal (0,0,1) then normalize; this serves as the axis of rotation. Next we take the normal again this time running the Dot Product of the Impact Normal and the Up Vector (0,0,1) when then take the arc cos (inverse of cosine) of the Dot Product; this serves as our angle. Next we make a Rotator from our Axis and Angle using the Rotator from Axis and Angle Function. We then Break the Rotator because our Particle System wants a Vector value not a rotator and in Cascade Rotators run from 0 (0 degs) to 1 (360 degrees) which is what we do next but because we are dealing with Radians which run from 0 (0 degs) to 2Pi (360 degrees) we need to normalize to that range. After normalizing for range we need to take the inverse of each float (*-1) which keeps the Particle rotating the correct way in relation to the floor. Finally we make a vector out of our broken rotator pieces making sure to align XYZ correctly to (Roll, Pitch, Yaw) and pass the resulting vector into our Vector Parameter.
Some warnings about this setup it is once at spawn only for each particle. Each particle can change it int. rotation but it cannot change dynamically once spawned. So, this system would work will on an environment that is not moving but dynamic environments will cause problems unless it moves between the particle spawns.
Thank You for your patience -
answered Mar 09 '15 at 08:24 PM
Lovecraft_K ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here