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

Moving GPUParticles2D with collision enabled causes particles to collide with nothing #77553

Open
Tracked by #61067
NewDefectus opened this issue May 27, 2023 · 10 comments

Comments

@NewDefectus
Copy link
Contributor

NewDefectus commented May 27, 2023

Godot version

4.2.dev1

System information

Windows 10, Forward+, Nvidia GeForce GTX 1050

Issue description

When a GPUParticles2D instance that has collision detection enabled and local coords disabled is moved (or its parent is moved, etc.), it appears that some of the particles it has generated will sometimes bounce as if the light occluders moved for them.

Steps to reproduce

The minimal reproduction project has a GPUParticles2D node following the cursor on the screen, emitting a ring of particles every second. A marked light occluder is added.

Fixing the cursor in place allows the particles to move freely and as expected; however, if one moves the cursor back and forth across the occluder while the particles are running, the collision bug will activate, sometimes causing the particles to bounce off nothing or even clip through the collider.

Minimal reproduction project

LocalParticles.zip

@Calinou
Copy link
Member

Calinou commented Jun 9, 2023

I can confirm this on 4.1.dev 06ccbfe (Linux, GeForce RTX 4090 with NVIDIA 530.41.03). Increasing Fixed FPS to 1000 or decreasing it to 0 does not resolve this issue.

It's worth checking whether this issue occurs in 3D too.

@NewDefectus
Copy link
Contributor Author

Confirmed for 4.2.dev1 and improved the minimal reproduction project. I'd be happy if this bug were prioritized higher as this is affecting some of the effects in my game.

@Calinou
Copy link
Member

Calinou commented Jul 27, 2023

I'd be happy if this bug were prioritized higher as this is affecting some of the effects in my game.

We don't know what is causing this issue, and contributors work on a best-effort basis. Additionally, we don't have that many rendering contributors who are knowledgeable with 2D particle collision.

@WagnerGFX
Copy link

I tried running the minimal reproduction project on 4.2 beta1 and didn't notice any issue. I even changed a few settings, but the collisions didn't show any strange behavior.

It might have been fixed already.

@NewDefectus
Copy link
Contributor Author

NewDefectus commented Oct 13, 2023

I tried running the minimal reproduction project on 4.2 beta1 and didn't notice any issue. I even changed a few settings, but the collisions didn't show any strange behavior.

It might have been fixed already.

I checked again now on 4.2 beta1, and it seems that the bug is still occurring on my end. For reference here's the kind of mouse movement I meant:

particles_bug.mp4

@WagnerGFX
Copy link

For reference here's the kind of mouse movement I meant:
particles_bug.mp4

Oh yeah. Now I can reproduce the bug 👀 (I was moving too slow to notice)

@WagnerGFX
Copy link

this is affecting some of the effects in my game.

I've discovered a workaround for the issue, at least for 4.2: Instead of moving the node, you can move the particle's emission_shape_offset and Visibility Rect.
With this the issue disappears, the downside is that process material needs to be unique for every particle node you use with this method.

It's worth checking whether this issue occurs in 3D too.

I've also made a scene to test the issue in 3D. From what I'm seeing, it doesn't seem to happen in 3D.
Some particles may get stuck on the walls, but that's a separate issue.

Well... I was mistaken before, so check the project below to be sure. 😅

LocalParticlesPlus.zip

@RayoROAR
Copy link

I've discovered a workaround for the issue, at least for 4.2: Instead of moving the node, you can move the particle's emission_shape_offset and Visibility Rect. With this the issue disappears, the downside is that process material needs to be unique for every particle node you use with this method.

Oh. My. God. You are a life saver! I stumbled upon the same problem and your solution works like a charm, many thanks!! :DD

@Blaine-McK
Copy link

this is affecting some of the effects in my game.

I've discovered a workaround for the issue, at least for 4.2: Instead of moving the node, you can move the particle's emission_shape_offset and Visibility Rect. With this the issue disappears, the downside is that process material needs to be unique for every particle node you use with this method.

It's worth checking whether this issue occurs in 3D too.

I've also made a scene to test the issue in 3D. From what I'm seeing, it doesn't seem to happen in 3D. Some particles may get stuck on the walls, but that's a separate issue.

Well... I was mistaken before, so check the project below to be sure. 😅

LocalParticlesPlus.zip

I tried this solution with no luck unfortunately. I did download op's LocalParticles example and did implement your solution in it and it worked. I think my issue is that I am also rotating. The mouse position never rotates

@WagnerGFX
Copy link

I've checked this issue using v4.4-dev6, it still remains the same for 2D, while the 3D particles seem to be working perfectly fine.

I think my issue is that I am also rotating.

From what I tested, it seems that any changes to the Particle2D's Transform will result in bugs. This includes moving, rotating and skewing.

The mouse position never rotates

In that case, you need to compensate the offset position with the particle's rotation. This may require some vector calculations.

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

5 participants