YouGroove Posted August 3, 2013 Share Posted August 3, 2013 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 ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted August 3, 2013 Share Posted August 3, 2013 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. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted August 3, 2013 Author Share Posted August 3, 2013 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 ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted August 3, 2013 Share Posted August 3, 2013 KeyDown() fires as long as it's down over multiple frames. If you want something to fire once use KeyHit() instead. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted August 3, 2013 Author Share Posted August 3, 2013 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 States will be in his own file like Key firing, Animations, player script will deal only with NPC and actions management . Quote Stop toying and make games 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.