wildcherrii Posted April 14, 2022 Share Posted April 14, 2022 I'm wondering, if I have a map entity that loads in with a script, then the Function Start() of that entity script loads a Sound File, do I need to keep track of these additional loads for when I do a clearmap(0 and load a new level ? or does these extra resources get removed on a new map load? What exactly gets removed from a world:Clear() ??? Im stuck on one major problem, I have entity:EmitSound() playing some footstep sounds as the enemy approach me. I want to kill the looping footstep sound when he gets close to me then stops. I've done intense reading on the forums and I see others had this delima to but no solution was recolved? This posts were back in 2014 and some point to dead 404 pages. So basically I have to destroy the entire entity and reload it just to stop a looping 3d emited sound ? And to add to the FUN ! this is what the docs say regarding EmitSound parms. Parameters sound: the new pick radius to set. range: the new pick radius to set. volume: the new pick radius to set. pitch: the new pick radius to set. loopmode: the new pick radius to set. source: the new pick radius to set. Good times. Quote Link to comment Share on other sites More sharing options...
Josh Posted April 14, 2022 Share Posted April 14, 2022 You can supply your own Source object to EmitSound and use that to control the sound: https://www.leadwerks.com/learn?page=API-Reference_Object_Source_Create https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_EmitSound Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
reepblue Posted April 14, 2022 Share Posted April 14, 2022 10 hours ago, wildcherrii said: What exactly gets removed from a world:Clear() ??? Entity types. Things like the Source Class, Joints, and assets will remain after the Clear call. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
wildcherrii Posted April 14, 2022 Author Share Posted April 14, 2022 OKay thank you both for the answers., If I'm loading some assets in a Script:Start() function for an NPC like this - self.footsteps = Sound:Load("Sound/footsteps/running.wav") Do I need to manually remove these assets when Im changing map files even though world:Clear() is being called? Quote Link to comment Share on other sites More sharing options...
Josh Posted April 14, 2022 Share Posted April 14, 2022 Yes, in Leadwerks, in the Script:Detach function you should free all loaded resources. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
wildcherrii Posted April 15, 2022 Author Share Posted April 15, 2022 Perfect, okay one last question and I think I can solve all my map changing woes. I load several prefabbed particle emitters throughout my map at certain times. ( via lua code ). Do these emitters die and release once they run out ? or do I need to track them as well and release them on map clear? Quote Link to comment Share on other sites More sharing options...
Josh Posted April 15, 2022 Share Posted April 15, 2022 World::Clear() will decrement the reference count of all entities in the world. Unless you have manually incremented the reference count, they will all be deleted. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.