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

asked Dec 12, 2019 in Projects by Abb1x (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.

answered Dec 12, 2019 by beebanoo (14 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 How to use this Q&A? before posting your first questions.