I would like to emit particles with global position (so they are left behind the parent node as it moves) with the parent node’s rotation angle. Is this possible? Can I set each particle’s rotation angle with code at creation, for example?
I don’t think it’s possible to control each individual particle directly from a Particle node. However, you can place the Particle node under the parent node and update its position in the _process(delta) function. This way, you can set its position and rotation to match a specific point using Vector2 or Vector3, depending on whether you’re working in 2D or 3D.
That’s the best approach I know so far
I’d like each particle to inherit the parent’s position, rotation, and scale. The effect I’m after is kind of an afterimage style, where the parent leaves a trail of fading afterimages of itself. Updating the particle node’s location in _process(delta) would move each particle, so I’d have to create a huge amount of particle nodes, one for each afterimage, which doesn’t sound great.
No, @Frozen_Fried is right. You put the particle emitter as a child of the object moving. If it rotates or moves, the child node inherits this automatically. The particle texture you set to your required ‘trail image’. You then emit one particle every 0.5 seconds or so, set it to fade to invisible, but not move, or move a bit if you want but only in the backward direction. This should be a relatively easy effect to set up. You do not have to control the after image particles at all.
When I try to set it with local coordinates, the particles move with the parent as well. How can make them “stick” to the screen instead of following the parent as well?
So I have been trying this out and it is not working! I cannot get the material of the particle to match the icon I am moving which is peculiar and is not what I was expecting.
So the only answer is to do it manually and not use particles.
PS It should definitely not be moving with your parent as well, as particles are independently being created. The only way this might happen is if you have some strange system of canvas layers which you are moving and not just moving the player itself. (My best guess anyway).
PS This is all I was using to get a rotating icon moving accross the screen with a trail of particles.
PS Personally though, if I was doing this myself for real, I would not use particles, I would use a pool of trail sprites that I could position and fade out under perfect individual control via code.
Can you show your particle settings? Mine doesn’t seem to work the same. I probably need to do a clean project to try and recreate what you have and move on from there.
When I am doing things like this I always start with a fresh test scene, just to try out something I am trying to achieve. Here, you can see the tree above, takes only 2 mins to create. Once you get whatever you want working in some way, then I spend the time trying to incorporate it into my game. This not only helps keep your game code clean, but game code sometimes introduces complexities that have nothing to do with the effect you are looking for, so learning how to do the effect first in a clean environment is often better, then you can amend it to fit your game environment.
Just to re-inforce that, here is my ingame testing folder full of test scenes of varying quality and complexity. (I delete this out regularly otherwise it would be about 100 folders big by now).
Thank you! I got it working with your instructions. I think the “Align Y” attribute of the CPU particles is very misleading. It states Align Y axis of particle with the direction of its velocity. This is what happens with GPU particles, but with CPU particles it aligns and scales them based on the parent.
A great tip about the testing scenes. I’ll definitely need to start doing that too! Makes it easier to isolate problems.