AudioStreamPlayer2D max distance

UnknownUserUnknownUser Posts: 1,393

Hi,

I am trying my first game in Godot (and in forever too), and am trying to implement some sound effect.

The variable max_distance is interesting, however, I am doing a 2D platformer which work with a camera 2D. And this max_distance seems to be related to the origin of the canvas. I would like it to be related to the distance of the center of the camera, or the player coordinates.

Is there something I didn't do? understand?

Thanks,

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 3,330Admin

    This discussion was caught in the moderation queue since you have not confirmed your account yet.

    Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.

    If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile:

  • UnknownUserUnknownUser Posts: 1,393

    Hi,

    It is done now. Should I repost my question or is it visible now?

    Thanks,

  • TwistedTwiglegTwistedTwigleg Posts: 3,330Admin
    edited September 23

    @MIE1981 said:
    Hi,

    It is done now. Should I repost my question or is it visible now?

    Thanks,

    It is visible when I replied, just future comments would fall into the moderation queue until someone on forum staff approved them. Now when you post, it won’t need manual approval.
    Thanks for verifying :)

    As for the question, I am unsure on why max distance is not working, though I have not used it myself. Is the player Camera2D node set to current?

  • UnknownUserUnknownUser Posts: 1,393

    Hi,

    Yes it is set to current, I don't know why it is based on the origin of the canvas. The camera is a child of a kinematics2D, do you think this could have an impact?

    Thanks,

  • TwistedTwiglegTwistedTwigleg Posts: 3,330Admin

    @MIE1981 said:
    Hi,

    Yes it is set to current, I don't know why it is based on the origin of the canvas. The camera is a child of a kinematics2D, do you think this could have an impact?

    Thanks,

    I do not think it being a KinematicBody2D should have any impact.

    Looking around, it seems it could be that the source code only considers the Viewport position, rather than the Camera2D, based on this QA post. I have only taken a small look through the source code for AudioStreamPlayer2D though, so I cannot say with certainty how it works nor if the viewport position being the only position taken into account is accurate.

  • MIE1981MIE1981 Posts: 1Member

    Hi,

    Thanks for looking at it. His answer is not very clear on how he made it work though. If I find a solution I will update this post.

    Thanks,

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file