-
Notifications
You must be signed in to change notification settings - Fork 71
Proposal to add the set_velocity method to the FmodEventEmitter3D node. #353
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
base: master
Are you sure you want to change the base?
Conversation
This method allows to report velocity to the fmod API to enable doppler effect for spatialized audio
Thank for the proposal.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the proposal !
void _notification(int p_what); | ||
virtual void _exit_tree() override; | ||
|
||
void set_velocity(const Vector3& velocity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be added to FmodEventEmitter template by adding a vector template param to it.
This way it will be implemented for both 2D and 3D emiters.
I'll move the crash related changes to a different PR and add more details about the crashes there. I'll also give it a shot at setting the velocity for the 2D node using a vector template param. About the emitter tracking another node. I think it does not match the current 'emitter reporting its own position' behavior. Maybe keep the |
When setting the velocity manually, the emitter is not really reporting its own speed either because the data must come from a different source that is set in the script. Being a Node2D/3D it has a proper position, but to have its own velocity we would have to make it a physic body, which would create other problems. So the simplest approach would be to set a PhysicBody node the emitter can track automatically every frame. It would remain optional and not setting a tracked node would give the same behavior we have today (no doppler effect). |
Adds the
set_velocity
method andvelocity
property to theFmodEventEmitter3D
node. This enables the doppler effect for spatialized audio.Proposed usage:
Changes
FmodEventEmitter3D.set_velocity
,FmodEventEmitter3D.get_velocity
andFmodEventEmitter3D.velocity
. Internally calls theget_3d_attributes_from_transform3d
method that already supported a velocity parameter.FModEventEmitter.h
file to prevent crashes when binding an event for the first time in the editor. Im not sure that all the checks are necessary, but it solves the issue. Requires further testing and maybe could be moved to a different PR.