0 votes

Hi,
How I can make that a KinematicBody hearts for a sound and when this occurs, it go to the sound location?
Thanks in advanced.

Godot version 3.2.3
in Engine by (353 points)

1 Answer

+1 vote
Best answer

Most times in game development you have to give your player the illusion that something is happening not actually do what is visually or in this case audibly represented.

Not that what you want to do isn't possible, it just has easier ways to implement it.
For example each Node that plays a sound can emit a signal broadcasting it's location
And have all interested KinematicBody connect and move accordingly when the signal is emitted

by (4,476 points)
selected by

An example.

func _ready():
    for node in get_tree().get_current_scene().get_children():
        if node is $AudioStreamPlayer3D:
            node.connect("finished", self, "_follow_sound", [node])

func _follow_sound(node):
    move_toward(node.global_trasform.origin)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.