How to rotate Particle2D?

Godot Version

4.2.1

Question

Hello, I’m making a top down tank game and I want the player to leave a trail of tread marks behind him. I’m using a particle emitter node but it doesn’t rotate with the tank so the tread marks always appear in the same rotation. Example:

If I turn on local coords the particle emitter rotates but it doesn’t leave any particles behind since it also follows the tank’s position.
If I change the particle angle through code, even already spawned tread marks will rotate with the player.

I searched the internet and I was only able to find one other post describing my same problem: Particle2D: Rotate particles once on creation?
The proposed solution there was to edit the shader material but in the current version of Godot the shader code has changed and I can’t follow that procedure anymore.

I would really appreciate some help.

How are you rotating the tank? Perhaps if you make the particle emitter a child of the sprite, it will rotate when the sprite rotates.

The tank rotation is simply controlled by:

	if Input.is_action_pressed("turn_right"):
		rotation += ROTATION_SPEED * delta
	if Input.is_action_pressed("turn_left"):
		rotation -= ROTATION_SPEED * delta

Making the particle emitter a child of the sprite doesn’t change anything since I’m already rotating the entire tank (a character2d node).

For clarity, the particle emitter rotates with the tank and I can see it sticking behind the tank as it moves around but the actual particles it emits never rotate, even if I manually change the particle emitter rotation in the editor.
Turning on local coords makes the particles rotate as the emitter rotates but then they also follow its position so they don’t get left behind the tank as the player moves around.

try Turn Flags
image
image

1 Like

So I’m not entirely sure and I know this is not the answer to your question but what if you make the emission particle a sphere and just emit more often?

I think the way you’re doing it, even if you figure out how to rotate it, it will look disconnected around turns. If it’s a small sphere you may get a better illusion of a trail.

Thank you, that finally worked!
I initially used a GPUParticles2D node and turning on align_y on it doesn’t fix the problem, but once I switched to CPUParticles2D and turned on the flag it finally made the particle emitter affected by its rotation (and scale too, weirdly).

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.