kbrodie Posted August 21, 2017 Share Posted August 21, 2017 I have a PhysicalTrigger in my world and when it's hit, it starts a few tracks that move a few pedestrians around. For this reason I created a few static vectors to keep track of various stats (that are needed while playing). In C++ I use "Unigine::Engine::get()->runWorldFunction" to "playTrack" in the script (see attachment), with with the filename of the track I want to start as argument. Then during the "update" method, all currently running tracks are updated. If I start multiple tracks in short succession, I get the following messages from Unigine: [some lengthy filename].track is being played. There are now 1 tracks running. [another lengthy filename].track is being played. There are now 2 tracks running. Array sizes are: 2, 1, 2, 1. Stats: index = 0, current time = 0. float current_time = single_run_time[index]; terraworld_leek.cpp:69: UserArray::get(): uninitialized key Stack dump: 0x0000: int: 0 Call stack: 00: 0x000047f2 update() Disassemble: float current_time = single_run_time[index]; 0x00004818: pushuavv single_run_time[index] 0x0000481b: setv current_time log.message("Stats: index = %i, current time = %d.\n", index, current_time); 0x0000481d: pushv index 0x0000481f: pushc string: "Stats: index = %i, current time = %d.\n" World::update(): world update function returned 0 (Filenames redacted for readability). The important line here is "Array sizes are: 2, 1, 2, 1." as according to me, it should not be possible for the various arrays to have different sizes (i.e.: it should have been: "Array sizes are: 2, 2, 2, 2."). So if anyone knows what happened here, I would greatly appricate it. Just to be clear, the "playTrack" method is called multiple times from the callback method in PhysicalTrigger (which means that the first 4 lines are all the result of a single trigger being triggered once). terraworld_leek.cpp Link to comment
alexander Posted August 22, 2017 Share Posted August 22, 2017 Hi, kbrodie! This may be due to multithreading. Try to use console command "engine_threaded 0". Or try to call "playTrack" in update method (in callback method simply add new item (filename) to some array, and execute it in update stage). Best regards, Alexander Link to comment
kbrodie Posted August 22, 2017 Author Share Posted August 22, 2017 Added 2 methods: "addTrack", which adds a string to an array of strings and "updateTrackLists", which sets an integer to 1 so that the "update" method knows it's safe to use that array of strings and call the "playTrack" method for each string. Once all the new tracks start playing, the array is emptied and the integer is set back to 0. I also needed to initialise the arrays with a size of 0 (e.g.: float single_run_time[0]), which is something I failed to notice on https://developer.unigine.com/en/docs/2.3/code/uniginescript/language/containers/ These 2 items combined solved my issue. Thanks for support, Kai Link to comment
Recommended Posts