godotengine / godot

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

[3.5.1] [4.0.rc1] Calling GPUParticles3D.restart() from AnimationPlayer doesn't seem to have an effect on the Editor #73043

Open hmans opened 1 year ago

hmans commented 1 year ago

Godot version

3.5.1, 4.0.rc1

System information

macOS, Apple M1

Issue description

Resetting a GPU particle effect by invoking its restart() function from an animation call track doesn't seem to work.

In the attached MRP, I have a one-shot GPU particle effect that is supposed to play at the start of my animation. For this, I've set up the animation to do two things:

But the call to restart() doesn't seem to have any effect.

Notes:

Screen recording:

https://user-images.githubusercontent.com/1061/218132825-21641f20-d17c-42c3-b73b-d01b6086e11b.mov

Steps to reproduce

Minimal reproduction project

MRP-Godot3-VFX-Timeline.zip

hmans commented 1 year ago

Just want to confirm that explicitly clicking on "Restart" in the GPU particles toolbar has the intended effect (even while the effect is still playing), both in 3.5.1 and 4.0.

image

TokageItLab commented 1 year ago

I remember @reduz saying something earlier about the necessity of a TrackType for particles.

hmans commented 1 year ago

A quick update. It seems that what's happening here is that Call Method tracks will only actually call methods when the scene or game is being run, but not within the editor. Which probably makes sense (you wouldn't want to run queue_free() while editing, etc.).

The documentation unfortunately doesn't mention this (at least I couldn't find anything about it), so if this is by design, I think the documentation should be updated accordingly.

Maybe a toggle can be edited to keyframe events in Method Call tracks so that, when set, the method is also invoked from within the editor?

Either way, the issue remains that it's extremely difficult to work on animations that orchestrate a number of one-shot particle effects. Being able to restart particle effects through animations would improve things significantly.

hmans commented 1 year ago

For anyone finding this, here's a quick and dirty workaround:

Step 1: create a custom class that extends GPUParticles3D and adds a new virtual property:

@tool

class_name HackedGPUParticles3D
extends GPUParticles3D

@export var hacked_emitting : bool:
  get: return emitting
  set(v):
    emitting = v
    restart()

Step 2: Use this for your GPU particle effects, or change the types of existing GPUParticle3D nodes to it (might require a scene reload/editor restart.)

Step 3: Instead of using a Call Method track, use a normal Property track, and set that property to true.

clayjohn commented 1 year ago

The fact that methods won't be called when running in the editor should be well documented (and possibly should be communicated to the user in editor).

At the very least it should be added to the docs here: https://docs.godotengine.org/en/latest/tutorials/animation/animation_track_types.html#call-method-tracks

TokageItLab commented 1 year ago

At the very least it should be added to the docs here

Indeed... I'll keep that in mind as I'm organizing the animation documentation now.

hmans commented 1 year ago

I'll leave this for you to decide, but in the interest of reducing noise here, maybe this issue should be rewritten or closed in favor of other (possibly new) issues, to better reflect the actual potential changes: