Jump to content

FlowGraph : Fire event once only


YouGroove
 Share

Recommended Posts

I have a script for FlowGraph

It runs in some updatePhysics() function and it detects if a key is down than CAllOutputs.

The problem is i only press the key a short time and the component continues to firing same key even if i don't press anything ?

Stop toying and make games

Link to comment
Share on other sites

Would have to see the script. Outputs will only be called if criteria is met so your script must set a value or something on KeyHit() and that value is checked in the Update() function and if it's true it'll keep calling the output them.

Link to comment
Share on other sites

My code is like that :

 

local window=Window:GetCurrent()

Script.enabled = true
Script.keypressed=false

function Script:UpdatePhysics()

--if self.enabled == true then

self.keypressed=false

if window:KeyDown(Key.Space) then  
self.keypressed=true
self.component:CallOutputs("Attack") 
end

if window:KeyDown(Key.Right) then  
self.keypressed=true
self.component:CallOutputs("Right") 
end
if window:KeyDown(Key.Left) then  
self.keypressed=true
self.component:CallOutputs("Left") 
end
if window:KeyDown(Key.Up) then  
self.enabled = false 
self.component:CallOutputs("Up") 
end
if window:KeyDown(Key.Down) then  
self.keypressed=true
self.component:CallOutputs("Down") 
end

if self.keypressed==false then
self.component:CallOutputs("Idle")
end

--end
-- if window == nil then
 -- self.entity:SetColor(1,1,0)
--end


end

 

In fact i juts press key one time, but event continues firing ?

Stop toying and make games

Link to comment
Share on other sites

Thanks.

May fault again , all is ok, in fact it was a variable boolean set to true when any key pressed, but it wasn't reset to false at the end of the PhysicsLoop.

Yep Flowgraphs works great, i'll have to test how to pass arguments instead of simple firing messages later

 

I'm making some adaptable generic character controller with Flowgraphs smile.png

States will be in his own file like Key firing, Animations, player script will deal only with NPC and actions management .

Stop toying and make games

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...