0 votes

I want that my player made an sound when he jump there is my code :

extends KinematicBody2D

const UP = Vector2(0, -1)
const GRAVITY = 20
var SPEED = 200
const JUMPHEIGHT = -400
var motion = Vector2()
func _physics
motion.y += GRAVITY
var friction = false
if Input.isactionpressed("uiright"):
motion.x = SPEED
h = false
elif Input.isactionpressed("uileft"):
motion.x = -SPEED
h = true
motion.x = 0
if isonfloor():
if Input.isactionjustpressed("uiup"):
motion.y = JUMPHEIGHT
motion = move
andslide(motion, UP)
if Input.is
if SPEED == 400 and friction == false:

func dash():
SPEED = 400
func onTimer_timeout():
SPEED = 200

in Engine by (18 points)

First of all, go watch a tutorial man, there are plenty(probably),
second of all, when the play simply jump you play the audio.

1 Answer

0 votes

First, you need to add AudioStreamPlayer to your player node and set the stream property to the audio file you want to play.
Second, during the handling of the jump input action, you need to reference that AudioStreamPlayer and call the play() method.

by (18 points)
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 Frequently asked questions and 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 [email protected] with your username.