burgelkat Posted April 16, 2016 Share Posted April 16, 2016 Hallo, i need a little help. I build a short script for a DummyTarget for the Shooting-Range Script.teamid=2--choice "Team" "Neutral,Good,Bad" Script.health=100--int "Health" entity = {} -- activate objekt function Script:Show()--in if (self.entity:Hidden()) then self.entity:Show() end end -- deactivate objekt function Script:Hide()--in if not self.entity:Hidden() then self.entity:Hide() end end If i Hide the Dummy at the beginning, my soldier is in idle position. If i now show the dummy (with a button or trigger), my soldier begins shooting. thats all fine so far. But if i hide the dummy again. the dummy is shortly hidden then the dummy is again visible by self. What is wrong with my script? Thanks for your help. Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted April 17, 2016 Share Posted April 17, 2016 What's the global 'entity' table here for? it doesn't look like you use it. But on to your original question, I don't see a problem in the code you've posted. Are you sure this trigger/button that runs 'Show()' it isn't being accidentally activated after you hide the entity? You could try adding a simple 'System:Print' line to the 'Show()' function to see if it's getting executed when you don't want it to. (Which I'd assume it is.) What exactly are you doing to execute the 'Show()' function? Quote Link to comment Share on other sites More sharing options...
burgelkat Posted April 17, 2016 Author Share Posted April 17, 2016 Hi, thats my script for the execute to show Script.enabled=true--bool "Enabled" Script.soundfile=""--path "Sound" "Wav Files (*.wav):wav" function Script:Start() if self.soundfile then self.sound = Sound:Load(self.soundfile) end end function Script:Use() if self.enabled then if self.sound then self.entity:EmitSound(self.sound) end self.component:CallOutputs("Use") end end function Script:Enable()--in if self.enabled==false then self.enabled=true self.component:CallOutputs("Enable") self.health=1 end end function Script:Disable()--in if self.enabled then self.enabled=false self.component:CallOutputs("Disable") self.health=0 end end function Script:Release() if self.sound then self.sound:Release() end end -- activate objekt function Script:Show()--in if (self.entity:Hidden()) then self.entity:Show() end end -- deactivate objekt function Script:Hide()--in if not self.entity:Hidden() then self.entity:Hide() end end --> thats the flow graph to your first note, you are right ('entity' table) i deleted it Edit: it appears to have something to do with my soldierAI script . If my soldier is dead, show and hide function with no problem Quote Link to comment Share on other sites More sharing options...
burgelkat Posted April 17, 2016 Author Share Posted April 17, 2016 solved. It was because of the SoldierAI script associated with an certain animation (shooting). Shooting never stops. So i changed self.animationmanager:SetAnimationSequence("Shooting",0.02) to self.animationmanager:SetAnimationSequence("Shooting",0.02,1,1,self,self.EndAttack) then i changed the Script.burstdelay to 2200 now there is time between the shooting sequence for the hide button. whether it is really correct what I did , no idea but it seems to work . (sometimes if i am fast with the button) Quote 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.