I made a little particle emitter for a spell for one of my character and the result behaves really weird under certain circumstances.
The particles will flow freely and nicely with no collision, as shown in the first part of the video.
With Rigid Collision and rotating clockwise, we can see collision on particles but only in the top left “quadrant” around the emitter. Anticlockwise, the same behavior happens, but on the lower-right quadrant.
With Hide On Contact the behavior is similar to Rigid, but instead of colliding with nothing, they disappear immediately.
There are no visible/enabled lightoccluder2d shapes in the scene except for the walls in the TileSet.
The second video shows the behavior of the particle collision when set to Rigid and the emitter is moved rapidly. This doesn’t always happens as bad as this.
I’m not entirely sure what to do with this. Any help appreciated.
PS: I’ll try to export the scene with the emitter and make it available somewhere.
Make sure the particles’ Visibility AABB (in 3D) or rect (in 2D) is large enough to cover the whole area particles will be in. You can increase its size manually, use the Generate Visibility Rect/AABB option in the Particles menu at the top of the editor (after selecting a particles node), or increase Extra Cull Margin in the inspector.
This is needed because particle collision only happens within its visibility AABB for performance reasons. Using a correctly sized AABB also ensures the particles don’t disappear when partially offscreen.
Alright, I’ve tried these option changes, to no avail.
I’ve regenerated the visibility rectangle.
Changed the Collision base size (from 2 to 1).
Changed the light mask/visibility layer just to test.
Draw order.
Couldn’t find the Extra Cull Margin option either manually or with the Filter search box.
I thought maybe the LightOccluder2D on the player somehow interfered, but no, it doesn’t. It sits behind the point where the particles are spawned. (20 px)
Fun facts:
While in the scene editor, if I rotate the emitter I don’t see the behavior.
The particles emitted, but still alive and in movement, are influenced by the emitter’s transform. Case in point, check the video below, you can see the H square (middle “button” at the bottom) refreshing the moment I let go of the RMB, but rotating the player placeholder after letting go of the mouse button will impact the projectiles that have been spawned and already in movement.
Ok, then it could be that when the player rotates the rotation of the particles is being rotated but the direction in which they travel is not change, thus when you rotate the player around the particles go backward.
I would try manually increasing the visibility rect size in the inspector to enlarge it. Make sure to move its origin as well so it’s expanded both ways.
If that’s the case, then the fault is in the particles code. The particle scene is attached to the player, so when the player rotates, that scene follows along.
Beside, the worst behavior is with Rigid collision. That’s when particles will fly every which way.
The Hide On Contact works fine when it collides by disappearing. But, at certain angles and the parent is moving (in this case rotating), they disappear immediately.
@Calinou
I’ve made the Visibilty Rect 300x300 centered on the scene, then removed the 20 pixels offset and put that on the scene before attaching it to the player.
Here’s what it looks like. There is ample space for the particles to live their 1s lifetime.
Just to reiterate: The rigid collision is fine if the emitter isn’t moving (rotated) and it collides. If the emitter moves the collision will send the particles every which way.
Is Local Coords enabled in the particles? If so, this will cause particles that are colliding to fly around due to being forced into the wall when the node (or one of its parents) moves.
You will probably need to design your particle system around global coordinates if you want to use rigid collision. Setting Inherit Velocity to 1.0 in ParticleProcessMaterial can help here.
The particle are not set as Local, but just for the sake of trying, I turned it local and it acts the same way, except worse with Rigid Collision; now the “rebound” goes off the screen leaving a very large smear while the particle is alive.
As for Hide On Contact, at certain angles, particles will still disappear if the emitter is in movement, rotation or otherwise. So, same as before.
The good news, for my project anyway, is that I don’t intend to use Rigid, only Hide on Contact.
Also, for sanity’s sake, when you mention Local Coords, you were speaking of Drawing->Local Coords, right? Making sure as I didn’t see another one, but I’ve been known to miss things, sometimes. XD
I’m not sure how to proceed with this, but I might just go and try to replicate the behavior in a separate test project and go from there, potentially posting a bug report.
Finally decided to create a basic project to test this out and it seems to be working fine.
Even with Visible Collision Shapes enabled, I don’t see why the particles are forced to behave the way they are… there has to be something obstructing them so they collide and go crazy (Rigid) or disappear immediately (hide on contact). The damnedest is that the behavior only happens when the emitter is moving (rotated or linearly).
The particle scene has an Area2D and its associated CollisionShape2D, but those two are not visible. Besides, the test scene is exactly the same scene (copied it) and it’s fine.