Archive 19/01/2023.

[SOLVED] SoundSource issue (GetSound and SaveXml)

Mike

I have some trouble with SoundSource component.
For example, adding a SoundSource in sample 11_Physics.lua:

    scene_:CreateComponent("Octree")
    scene_:CreateComponent("PhysicsWorld")
    scene_:CreateComponent("DebugRenderer")

	-- Create a sound channel
	local musicNode = scene_:CreateChild("Music1")
	local source = musicNode:CreateComponent("SoundSource")
	local music = cache:GetResource("Sound", "Music/Ninja Gods.ogg")
	source.soundType = SOUND_AMBIENT
	music.looped = true -- Loop play
	source:Play(music)
	print(source.sound)

source.sound returns nil and source path is not created in the saved xml file when pressing ‘F5’ key (no “Sound” attribute).
Same issue with AngelScript.

I’ve tried to create the same SoundSource in the Editor then save it and it works fine:

source path is saved as
<attribute name="Sound" value="Sound;Music/Ninja Gods.ogg" />
cadaver

It was an issue of compressed sound resource ref not being serialized, as the sound_ variable was not assigned in that case. Should be fixed now.

Mike

Works great, as usual :stuck_out_tongue: