Manually spawn particle at position

Godot Version

4.3

Question

Im trying to manually spawn a particle of an already existing GPUparticlesystem at a specified position.

image

I get positions from the world just fine, its just the spawning that is bugging me.

var tp = raycast_to_world(p)
var t = Transform3D.IDENTITY
t.origin = tp
particles.emit_particle(t,Vector3.ZERO,Color.WHITE,Color.WHITE,0)

this code just spawns particles at 0.0.0

(if i replace the emit code with an instantiate() all that, the tp i get from raycasting are fine)

Has anyone got experience with this?

I not sure if that is the problem but you’re using an invalid flag, doesn’t exist the flag 0 for this function, always use the enumerators to avoid this, try:

particles.emit_particle(t, Vector3.ZERO, Color.WHITE, Color.WHITE, GPUParticles3D.EMIT_FLAG_POSITION)

1 Like

i will try this! thanks.

hmm didnt help. the particles (i think there are many on top of each other, but i could be wrong) does spawn somewhere else though.

what im doing is this (which works perfectly well if i just spawn objects at those positions):

	for row in range(grid_size):
		for col in range(grid_size):
			var tp = round(target.global_position)
			var p = tp - Vector3(grid_size * resolution / 2, 0, grid_size * resolution / 2) + Vector3(row * resolution, 0, col * resolution)
			
			p.x = round(p.x)
			p.z = round(p.z)
			
			var terrain_position = raycast_to_world(p)
			var t = Transform3D.IDENTITY
			t.origin = terrain_position
			#Here ive deleted my original spawn objects code (which works)
			#I even try this out of desperation--->
			#particles.global_position = terrain_position
			#particles.process_material.emission_shape_offset = terrain_position
			particles.emit_particle(t,Vector3.ZERO,Color.WHITE,Color.WHITE,GPUParticles3D.EMIT_FLAG_POSITION)
			

Hm i have no idea, i tested the function with the correct flag and the particle was spawned in the correct place, from your print your GPUParticles3D has a particle material assigned, try remove the particle material and make sure you’re drawing something in the draw pass 1

Ok so I guess the p mat has some placement logic in it…
wonder if I then have to learn how to do my own p mat where position is not being set.

Nothing works. Now I got a basic process shader for the particle system. And it seems like it still just spawns one particle at one spot.

It seems I can’t do the emit particle call 64 times a frame and manually set positions before each of those calls.

Did you try to spawn multiple particles in one frame at different specific positions?

Yes, if the amount property in GPUParticles3D is equal or bigger the amount of particles i spawn they work as expected

1 Like

Oh… The amount. I’ll try this ASAP. Thanks!

Worked. Thanks so much. Didn’t even cross my mind. :smiley::smiley:

Wasn’t that ASAP but glad that worked haha

1 Like

Indeed. Hobby project time works in mysterious ways. :no_mouth:

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