Skip to content

play_one_shot() in EventEmitter doesn't apply parameters #406

@JaccomoLorenz

Description

@JaccomoLorenz

The event parameters aren't applied when play_one_shot() is called on the EventEmitter, it always used the default values.

Example:

# This doesn't apply the parameters
set_parameter("impact", 500)
set_parameter("surface_type", "metal")
play_one_shot()
# This works like expected
var instance = FmodServer.create_event_instance_with_guid("{69afe3db-6810-4d93-83be-efdd81e23827}")
instance.set_parameter_by_name("impact", 500)
instance.set_parameter_by_name_with_label("surface_type", "metal", true)
instance.start()
instance.release()

Seems like apply_parameters() always applies the parameters to "_event" not to the variable "event" field used inside the _play method, so new created one shot events don't get the proper parameters.

template<class Derived, class NodeType>
    template<bool is_one_shot>
    void FmodEventEmitter<Derived, NodeType>::_play(bool should_start_event) {
        Ref<FmodEvent> event;
        if (is_one_shot) {
            event = _create_event();
        } else {
            if (_event.is_null() || !_event->is_valid()) { _load_event(); }

            event = _event;
        }

        if (event.is_null()) {
            // No event loaded, nothing to do here
            return;
        }

        event->set_volume(_volume);
        apply_parameters();

        set_space_attribute(event);
        if (!_programmer_callback_sound_key.is_empty()) {
            event->set_programmer_callback(_programmer_callback_sound_key);
        }

        if (!should_start_event && event->get_playback_state() != FMOD_STUDIO_PLAYBACK_STOPPED) {
            return;
        }

        event->start();
        event->release();
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions