pickleplayer Posted August 18, 2015 Share Posted August 18, 2015 I'm having trouble getting birds on the screen to fly away when a function is called. here is a snippet of the codeif v.prefab == "robin" then v:DoTaskInTime(0.5, function(v) v:PushEvent("flyaway") end) v:PushEvent("flyaway") v.sg:GoToState("flyaway") v.PushEvent("ShouldFlyAway") print("IIIIM LIKE A BIIIIRD")end^I've tried all of the above codes, but nothing seems to get them to fly away. In the birds stategraph, there is a "flyaway" state, so I know it exists.And I always get the "IIIIM LIKE A BIIIIRD" to show up in the console depending on if there is a robin on screen or not, so I know I'm targeting them correctly. I just don't know why they aren't flying. They'll often raise their wings for a fraction of a second when the function is called, as if they're about to take off, but then they never do. Link to comment Share on other sites More sharing options...
Finerlobster Posted August 18, 2015 Share Posted August 18, 2015 And the "gohome" event? Link to comment Share on other sites More sharing options...
DarkXero Posted August 18, 2015 Share Posted August 18, 2015 if v.prefab == "robin" then v.sg:GoToState("flyaway") print("IIIIM LIKE A BIIIIRD")endShould be enough to make the bird fly away. Link to comment Share on other sites More sharing options...
pickleplayer Posted August 18, 2015 Author Share Posted August 18, 2015 if v.prefab == "robin" then v.sg:GoToState("flyaway") print("IIIIM LIKE A BIIIIRD")endShould be enough to make the bird fly away.Exactly; but it doesn't. All the other bits of code up there are other things I've tried by themselves, but also didn't work. Link to comment Share on other sites More sharing options...
DarkXero Posted August 18, 2015 Share Posted August 18, 2015 @pickleplayer, therefore the error is in the code you didn't give. If I do c_find("robin").sg:GoToState("flyaway") when a robin is on screen, it will fly away. Link to comment Share on other sites More sharing options...
pickleplayer Posted August 19, 2015 Author Share Posted August 19, 2015 @pickleplayer, therefore the error is in the code you didn't give.If I do c_find("robin").sg:GoToState("flyaway") when a robin is on screen, it will fly away.So then my code snippet is right?Alright thanks, I'll take a look at the rest of my code when I get home and figure out what's going on Link to comment Share on other sites More sharing options...
DarkXero Posted August 19, 2015 Share Posted August 19, 2015 So then my code snippet is right? It works, yes.And also, v.sg:GoToState("flyaway") is just enough. Link to comment Share on other sites More sharing options...
ZupaleX Posted August 20, 2015 Share Posted August 20, 2015 (edited) It is probably coming from the fact that the bird is playing an "attacked" animation or something similar. It blocks then the execution of the command GoToState("flyaway").You can fixing it by using something likeTheWorld:DoTaskInTime(0.5, function() target.sg:GoToState("flyaway") end) Edited August 20, 2015 by ZupaleX Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now