Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown global transform when Particles2D is set to false for local coordinates and connected to PhysicsBody2D #46933

Open
Tracked by #45334
joubertdj opened this issue Mar 12, 2021 · 2 comments

Comments

@joubertdj
Copy link

Godot version:
Using Godot 3.22, and also verified with Godot 3.2.4rc4

OS/device including version:
Windows 10 Pro
OpenGL ES 3.0 Renderer: GeForce RTX 2070 with Max-Q Design/PCIe/SSE2

Issue description:
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:

ar _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 I am missing a specific transform to this?

Minimal reproduction project:
I have added a minimal project that demonstrates the behavior:
Bug_Capture_Rect.zip

This example has two identical particle system overlapping, one is set to true and the other false for the Local Coords setting, I then display the global and local values recieved.

@joubertdj joubertdj changed the title Unknown global transform when Particles2D is set to Unknown global transform when Particles2D is set to false for local coordinates Mar 12, 2021
@joubertdj
Copy link
Author

joubertdj commented Mar 12, 2021

The physics connected to the particle2d seems to maybe cause the issue. The first example I posted actually works ... when I added the chain and Physics things went weird (you can click and drag the ball to interact with the lantern/chain):

Lantern.zip

@joubertdj joubertdj changed the title Unknown global transform when Particles2D is set to false for local coordinates Unknown global transform when Particles2D is set to false for local coordinates and connected to PhysicsBody2D Mar 12, 2021
@pouleyKetchoupp
Copy link
Contributor

I can confirm in 3.2.3 and 3.2.4 RC5:
The returned rect seems wrong in the Lantern case where the particles are attached to a chain of rigid bodies.
In the project from the original post, it works ok and it seems capture_rect is always in local coordinates, whether local_coords is enabled or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants