godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.64k stars 20.1k forks source link

GPUParticles2D offsets on collision with LightOccluder2D but ONLY when the Camera2D node is rotated. #92049

Open Awfyboy opened 3 months ago

Awfyboy commented 3 months ago

Tested versions

System information

Windows 11 - Godot v4.2.1 - Compatibility Renderer - Intel UHD Graphics 630

Issue description

particle_collision_bug_godot

This is a basic GPUParticle2D node colliding with a LightOccluder2D. It has collisions mode set as Rigid and a Bounce of 0.6. While it works without the Camera being rotated, it seems to break when the Camera rotates. The particles offset after it collides with the Light Occluder, and it ONLY happens when the Camera2D node is rotated. This issue occurs regardless of Bounce or Friction being greater than 0. It always occurs when collisions mode is set as Rigid. No other option seems to cause the issue. I have checked the project in Mobile and Forward+ as well and the issue persists.

The scale of the particles also doesn't change the outcome nor does the rotation. Use Scale is turned on, but turning it off doesn't solve the issue either. Local Coords option on the Particle node is off so I don't think that is the issue, and the GPUParticles2D node is not the parent of the Camera2D node so I don't think it's an issue with SceneTree order either. Fixed FPS is set to 0 in this example, but setting it to the default value of 30 doesn't solve the issue, nor does setting it to a higher value. This appears to be an issue with how physics is calculated on Particle instances.

Steps to reproduce

  1. Create a new project and make a new scene.
  2. Add a LightOccluder2D to your scene.
  3. Add a GPUParticles2D and set collision mode to Rigid.
  4. Add a Camera2D, rotate the node, then turn Ignore Rotation off.

Minimal reproduction project (MRP)

GodotParticles2DCollisionsBug.zip

greycheeked commented 3 months ago

I think I ran into the same problem. With the help of a test particle shader, I was able to make the problem a little clearer. When the particles collide, I set their speed to 0 and increase their lifetime slightly. In the video you can see how the particles stick to the obstacles. After I rotated the camera a little, the particles suddenly stick to invisible obstacles. Based on the shape and position, I would say that the camera angle has been doubled during the particle collision. (I have of course also tried other angles).

https://github.com/godotengine/godot/assets/92092511/417f55b9-22b1-4217-a14f-ab9f0f5d9ded

Awfyboy commented 3 months ago

Oh, interesting. So it appears to be a miscalculation of the viewport rotation?

greycheeked commented 3 months ago

Unfortunately, I don't understand enough about it, but I'm assuming that during particle collision detection, a transformation is wrong.

DennisFan11 commented 5 days ago

also on v4.3.beta3.official [82cedc83c]