Rick Posted February 7, 2014 Share Posted February 7, 2014 https://dl.dropboxusercontent.com/u/1293842/AnimationTutorial.rar Run this in release mode and you'll see it gives an error. In debug mode it runs, but the explosion emitter doesn't work. I have the main character shooting (raycasting) and it plays a cartoon laser type sound. It does the raycasting out. When it hits the bomb I hide the model (because we can't Release() them yet without crashing the game), I play an explosion sound, and the last thing I need to do is to play the explosion emitter I have). I made the bomb character a prefab, which has an emitter prefab assign to it. I then have a spawner script spawning bomb prefabs. If in debug mode the game runs, but still no emitter showing. If in release mode it crashes when it creates a bomb prefab instance with the error: Object reference count error. If I comment out the loading of the explosion emitter prefab, then I don't get this error in release mode. Link to comment Share on other sites More sharing options...
YouGroove Posted February 7, 2014 Share Posted February 7, 2014 To resume, you can't play it one time only ? Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted February 7, 2014 Author Share Posted February 7, 2014 I tried saving an emitter off as a prefab and I have the following script that loads the prefab and calls Play() on it in the collision. However I get an error saying Play is a nil value. Any ideas as to why that would be? The explosionEmitter is a valid entity, but Play() doesn't seem to be exposed for some reason. import "Scripts/AnimationManager.lua" Script.ExplosionEmitterPrefab = "" --path Script.Target = nil --entity Script.Speed = 5 --int Script.Accel = 15 --int Script.AnimSeq = {} Script.AnimSeq.Idle = 1 Script.AnimSeq.Walk = 0 function Script:Start() self.entity:SetKeyValue("type", "bomb") self.animMgr = AnimationManager:Create(self.entity) self.explosionEmitter = Prefab:Load(self.ExplosionEmitterPrefab) end function Script:UpdatePhysics() if self.Target ~= nil then self.entity:Follow(self.Target, self.Speed, self.Accel) self.animMgr:SetAnimationSequence(self.AnimSeq.Walk, 0.03, 200) end end function Script:Collision(entity, position, normal, speed) local type = entity:GetKeyValue("type", "") if type == "player" then self.entity:Hide() self.entity:SetMass(0) local pos = self.entity:GetPosition() pos.y = 1 self.explosionEmitter:SetPosition(pos) self.explosionEmitter:Play() end end function Script:Draw() self.animMgr:Update() end Link to comment Share on other sites More sharing options...
YouGroove Posted February 7, 2014 Share Posted February 7, 2014 You should ask to Josh. I used particles, but not in prefab and i didn't tested stop/start. I'll do a test tonight. Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted February 7, 2014 Author Share Posted February 7, 2014 You should ask to Josh. That's why I made this post in Bug Reports I have the main character shooting (raycasting) and it plays a cartoon laser type sound. It does the raycasting out. When it hits the bomb I hide the model (because we can't Release() them yet without crashing the game), I play an explosion sound, and the last thing I need to do is to play the explosion emitter I have). I made the bomb character a prefab, which has an emitter prefab assign to it. I then have a spawner script spawning bomb prefabs. If in debug mode the game runs, but still no emitter showing. If in release mode it crashes when it creates a bomb prefab instance with the error: Object reference count error. If I comment out the loading of the explosion emitter prefab, then I don't get this error in release mode. Link to comment Share on other sites More sharing options...
YouGroove Posted February 7, 2014 Share Posted February 7, 2014 That's what i was going to ask : how to release some entity easyly ? I mean all that it contains like physics, sound Lua table etc ... I know Release() just crashes even for simple entities. ------------- About spawning what i recommend : Use a pool of objects some PoolManager.lua Let's say you can have 10 bombs at same time : create a pool of 10 - create 10 at start - init them as Hide(), Stop() - or place them at Y=-5000 also when you need to spawn one bomb : - Take one from the pool array - place it at spawnning position - Start it's script - Show() call to display it When the bomb is out : Return it to the pool - Call Hide(), Stop() script - and place it at Y=-5000 also That's 100 times faster than creating/destroying objects. Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted February 7, 2014 Author Share Posted February 7, 2014 You are right that would be faster, but creation speed doesn't seem to be an issue so I'm not worried about it right now. Just want the basics working first. Optimizing something that isn't causing issues isn't something I'm interested in 1 Link to comment Share on other sites More sharing options...
Josh Posted September 13, 2014 Share Posted September 13, 2014 Since your project does not include any code needed to produce this bug I cannot evaluate this. It works fine. I do not see your code above in the bomb Lua script. 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