Jump to content

Making birds fly away?


Recommended Posts

I'm having trouble getting birds on the screen to fly away when a function is called.

 

here is a snippet of the code

if 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

if v.prefab == "robin" then    v.sg:GoToState("flyaway")    print("IIIIM LIKE A BIIIIRD")end
Should 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

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 like

TheWorld:DoTaskInTime(0.5, function() target.sg:GoToState("flyaway") end)

Edited by ZupaleX
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...