0 votes

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())
print(_tempParticlesRectangle)
_tempParticlesRectangle = get_node("Lantern_Basic_Particle_Smoke").capture_rect()
print(_tempParticlesRectangle)
var _tempParticlesTransform = get_node("Lantern_Basic_Particle_Smoke").get_global_transform()
_tempParticlesRectangle = _tempParticlesTransform.xform(get_node("Lantern_Basic_Particle_Smoke").capture_rect())
print(_tempParticlesRectangle)

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,

Dawie

Godot version 3.2.2 and tested it in 3.2.4rc4
in Engine by (12 points)

1 Answer

0 votes

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()
        update()

    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())
        draw_rect(_tempParticlesRectangle,Color(1,0,0,0.5))
by (2,058 points)

Estenbanmolca,

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?

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.

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?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.