This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

3-D in 2-D, rotations seem off

nolannolan Posts: 19Member

Hey, need help with some audio work, sample here.

I'm trying to use 3-D audio in 2-D by creating an invisible viewport with a camera and listener, then syncing any AudioStreamPlayer3D nodes with Node2D parents. I'm doing this because 2-D audio doesn't support a top-down perspective centered on the player, only on mid-screen. This almost works in that positions do update, and rotating does move sounds around the listener. But my sounds are off by 90 degrees, and I'm wondering if there's some difference in 2-D/3-D rotation that I'm not accounting for.

Specifically, my example creates a player at (0, 0) and a sound at (10, 0). The player's default rotation is 0, so I'd expect the sound to be in front. But instead, it is off to the right. Left/right-arrows rotate, and rotation sounds as it should, but the angle is off.

Further, if I comment out rotation, nothing changes. To me, this suggests a difference between 0 rotations in 2-D and 0 rotations in 3-D. So I don't think this is specifically an audio issue, but instead a matter of how I'm converting a 2-D object's global_rotation to 3-D--I mean, I'm just setting it directly, but I'm wondering if I need to transform the rotation somehow before applying it to the 3-D stream.

Thanks for any help. Been banging my head on this one for weeks and don't know what to do.


  • nolannolan Posts: 19Member

    I managed to solve this, and the latest code in the repo does what I want (though it still needs a bit of cleanup) but I don't understand why.

    I'm using look_at to explicitly set a direction and up vector rather than just running rotate on a specific axis. I realize my up vector is (0, 0, -1) but I'd have expected rotate_z to basically do what my current code is, albeit more succinctly.

    Thanks for any explanations.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.