What is the global transform of particles when their Local Coords have been set false?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By joubertdj

To whom it may concern,

I have a 2d lantern hanging from a chain. The lantern has three particles2d effects on it: Sparks, fire, and smoke. When I set the Local Coords to false for all three particle effects the behavior is expected and when I bump into lantern, the lantern swings and the particles are “left” in global coordinates, as expected.

My intention was to disable emitting of the “fire” particles if the “capture-rect” result is not within the rectangle of the sprite. The result of the “capture-rect” (when the Local Coords is disabled) is in a certain global transform that I cannot “determine”? I have tried the following:

var _rootGlobalTransform = get_tree().root.get_child(0).get_global_transform()
var _tempParticlesRectangle = _rootGlobalTransform.xform(get_node("Lantern_Basic_Particle_Smoke").capture_rect())
_tempParticlesRectangle = get_node("Lantern_Basic_Particle_Smoke").capture_rect()
var _tempParticlesTransform = get_node("Lantern_Basic_Particle_Smoke").get_global_transform()
_tempParticlesRectangle = _tempParticlesTransform.xform(get_node("Lantern_Basic_Particle_Smoke").capture_rect())

The first two print instructions provides the same result, hence my assumption is that the coordinates are based upon the global transform, however, the information does not make sense. The third one starts of by saying the rectangle starts at 0,0. If I just enable the Local Coords for the particle system, then (apart from the obvious that the particles move with the lantern), then the result of “capture-rect” makes sense and is as the particles is (if I do the last “print” section as mentioned).

Either the “capture-rect” is computed incorrectly when the Local Coords are set to false or my transforms are totally “whacky” or I may just totally not understand … can someone please assist?

Best regards,


:bust_in_silhouette: Reply From: estebanmolca

Although I don’t know if I fully understand the problem or what you want to achieve, I did a little test on a node with a child particle. To see the result I use the drawrect () function and I only noticed a problem:
When I turned off local_coords, the drawing of the rect would appear in the position 0,0 of the world, after a second or so, everything was normalized. It seems that converting the coordinates takes a few frames to start. I suspect that you were reading the print values in the first frame. To fix it I set the particle property, preprocess to 1. I leave the script to use:

func _physics_process(delta):
    	$Lantern_Basic_Particle_Smoke.position= get_global_mouse_position()
    func _draw():
    	var _tempParticlesTransform = get_node("Lantern_Basic_Particle_Smoke").get_global_transform()
    	var _tempParticlesRectangle = _tempParticlesTransform.xform(get_node("Lantern_Basic_Particle_Smoke").capture_rect())


Thanks for that. However look at: GitHub Report/Example

I made an example to show what the behavior is in a minimalistic way.
Would you care to test that and comment please?

joubertdj | 2021-03-12 10:53

I already tried the project, but the truth is that I have little and nothing to say. My knowledge about matrices and transformations is still limited. For example these lines:

var tempGlobalGlobalTransform = get_child (0) .get_child (0) .get_global_transform ()
tempString + = "\ n \ n Particles2D_Global capture_rect xform_inved:" + str (tempGlobalGlobalTransform.xform_inv (get_child (0) .get_child (1) .capture_rect ()))

Are you reversing the transformation of the second particle using the transformation of the first particle?
I think it is the print that shows coordinates (-500, -500)
Anyway, I repeat my knowledge is still limited. But if you need anything else, here I am.

estebanmolca | 2021-03-12 11:57

I am no maths guru either. However, any help, will always be apprecited, I might just be doing something silly.

I updated the GitHub project with the physics portion attached. Check it out please?

joubertdj | 2021-03-12 15:14