This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hi...,

my fileSystem looks like this:

res://
level
  player
    player_script.gd
    media
       jump_sound.wav

so the absolute path for my sound file is "res://level/player/media/jump_sound.wav".

In playerscript.gd I would like to load jumpsound.wav with a relative path like this (because, when I move the folder player, the script is broken with an absolute path):

var jump_sound = load("media/jump_sound.wav")  # doesn't work

Is there a way for relative load paths in GDscript?

Thanks

Mike

Godot version 3.5.1
in Engine by (169 points)

1 Answer

0 votes

if you use "preload" instead of "load" that should work

by (1,346 points)

Hi rossunger, preload() works, great, thank you

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.