Jump to content

Show and Hide


burgelkat
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

post-13719-0-17851300-1460887527_thumb.png

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...