- Home /
Can shuriken Particles be affected by LateUpdate animation?
I have a fire-breathing monster whose head transform is being set in LateUpdate (courtesy of FinalIK's AimIK and LookAtIK functions). I'm currently using shuriken particle emitters, childed to the head joint, to create a flamethrower effect. However the particle systems emit their particles before LateUpdate, meaning that they don't take FinalIK's procedural animation into account.
If I set emission to Local space, the problem is barely noticeable, as the flames only lag one frame behind the slow-moving head, but if I set it to World, the emitters ignore the procedural head transform and send flames out at completely the wrong angle.
Using IK to aim my monster's attacks is integral to my gameplay, but I want the flame particles to exist in World space so they behave more realistically than the perfectly straight ray that Local space produces. Is there any way to make Shuriken particles take LateUpdate transforms into account, or should I start looking at alternate particle systems?
Answer by Partel-Lang · Oct 21, 2015 at 07:41 AM
Hey,
Let's say you wanted to have a ParticleSystem that emits steam from one of the character's ears. Set up the ParticleSystem to the position of the ear, but don't parent it to the head. Make an empty gameobject instead, name it "Target" and put it to the exact same position and rotation and parent the Target to the head instead. Then add this script to the ParticleSystem gameobject:
public Transform target; // The Transform parented to one of the character's bones
private Vector3 targetPosition;
private Quaternion targetRotation;
void Start() {
LateUpdate();
}
// Move this ParticleSystem to the target's last frame position before it emits
void Update() {
transform.position = targetPosition;
transform.rotation = targetRotation;
}
// Read the world space position and rotation of the target after procedural effects have been applied
// NB! Make sure this script is set to a higher value than FinalIK components in the Script Execution Order!
void LateUpdate() {
targetPosition = target.position;
targetRotation = target.rotation;
}
NB! Make sure this script is set to a higher value than FinalIK components in the Script Execution Order!
Cheers, Pärtel
Answer by CodeMasterMike · Feb 18, 2015 at 06:49 AM
The world vs local space simulation is only used for moving and rotating the particles. The particles do exist in, and interact with, the world regardless which of these simulation options you use.
Using world simulation, then the particle uses the global coordinate system (i.e. y-axis is always up). Using local simulation, then the particle uses the local coordinate system, which can differ depending on the object/parent object (i.e. the y-axis doesn't always have to point up as with the world space).
Thanks, but I understand the difference between world and local simulation space. $$anonymous$$y question is whether it's possible to emit particles taking LateUpdate animations into account.
As far as I know, you can't change when the particles are updated internally.
One way you could do it, is that you emit, update (position and rotation and whatnots) all the individual particles yourself in the LateUpdate method, ins$$anonymous$$d of using the internal ParticleSystem update.
Build my own particle system? Eek, no, I'm too lazy for that. Ins$$anonymous$$d I've created a script that aligns the emitter to the joint in LateUpdate, and I've set the script to execute after the FinalI$$anonymous$$ scripts. It still lags a frame behind, but otherwise works as intended.
Your answer
Follow this Question
Related Questions
Random 2d particles in Particle_system from spritesheet 1 Answer
What's the best way to stop particles? 1 Answer
VertexLit particles not affected on all directions 0 Answers
Aura - PLZ HELP 0 Answers
Very strange particle question. 0 Answers