playMaker

Author Topic: State finishes before all actions are executed.  (Read 1866 times)

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
State finishes before all actions are executed.
« on: December 14, 2017, 07:08:56 AM »
Hi,

I have a new issue that I never encountered before. I have two game objects, one "Fireball" and one "game manger". When the fireball hits a player it calculates the damage done and then updates the health on the player. When this is done it sends a RPC call to a game manager to delete the fireball. Pretty simple.

Well, sometimes, (I have not manage to see a pattern, but if you fire rapidly for instance) the "send event - update health" do not trigger. The calculation is done but on action do not go off, then the next state(Destroy fireball) start without the previous action "send event" as played. I have some pictures to easier understand.

I have worked a lot with breakpoints to try to find the issue here but with no obvious answer. I tried to enable the "Action Sequence" to be sure that EVERY action is done before it goes to the next state. But with no success.

IF i add a delay to the "destroy fireball" with say, 0.5s everything works fine and the all events trigger as they should 100% of the time.

It's like the "destroy object" triggers before the "send event" has happened, so the fireball has disappeared and can not finish the previous states. Maybe its due to delay over the network?

Any inputs?

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: State finishes before all actions are executed.
« Reply #1 on: December 14, 2017, 08:01:18 AM »
With the action names changed it's difficult to see what you are doing, however i get the feeling that the problem is your Health Manager.

After you send the Update Health Event, does the Health Manager try and get a variable from the Bullet perhaps?

Or do you have a set dammage amount already in your Health Manager?

If the Fsm moves to the next state, the send event must have fired so the problem  might be on the receiving end.
« Last Edit: December 14, 2017, 08:20:11 AM by LordHorusNL »

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: State finishes before all actions are executed.
« Reply #2 on: December 14, 2017, 08:16:58 AM »
With the action names changed it's difficult to see what you are doing, however i get the feeling that the problem is your Health Manager.

After you send the Update Health Event, does the Health Manager try and get a variable from the Bullet perhaps?

Or do you have a set dammage amount already in your Health Manager?

If the Fsm moves to the next state, the send event must have fired so the problem  might be on the receiving end.

Hi!

Thank you for your answer!

Yeah, I forgot that I changed the names of the actions. The actions are:

Get FSM Float - Get the current health of the player that the bullet collide with.
Float subtract - Subtract the current health with a damage variable that is fixed in the bullet (this game object)
Set FSM float - Set the new health in the health variable in the health manager
Set killer name - This has nothing to do with the calculation. it just stores who it the player
Update current health - Send event to the health manager to update the health bar.

I've attached a picture of the health manager. It is not using any variables in the bullet.

The thing is that it updates sometimes but not every time. And if the ad the delay on the "destroy game object" everything works.

Mustn't it has something to do with the deletion of the the fireball?

I can make a GIF of the process if you would like.

(I included a picture of the health manager as well)

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: State finishes before all actions are executed.
« Reply #3 on: December 14, 2017, 08:19:55 AM »
In your spell manager "RPC Spell Fireball" when you shoot in rapid succession is the reference to your bullet not being overwritten? Like this:

Shoot bullet 1
Shoot bullet 2
Bullet 1 hits
Destroys bullet 2 because your bullet reference has changed to bullet 2 in your spell manager.

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: State finishes before all actions are executed.
« Reply #4 on: December 14, 2017, 08:46:52 AM »
In your spell manager "RPC Spell Fireball" when you shoot in rapid succession is the reference to your bullet not being overwritten? Like this:

Shoot bullet 1
Shoot bullet 2
Bullet 1 hits
Destroys bullet 2 because your bullet reference has changed to bullet 2 in your spell manager.

Hmm...yes that might be the case. This made me think: "Why do I even have a RPC for the destruction of the fireball, in the first place?" The fireball is a local instance due the its crated through a RPC.

I just removed the whole "RPC destroy fireball" with a simple "destroy self" and now it works!

I must have had some kind of mental fart haha

Anyhow. thank you so much for your help and time, really appreciate it!

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: State finishes before all actions are executed.
« Reply #5 on: December 14, 2017, 08:55:51 AM »
Indeed if all your bullets are locally instantiated there really is no need for the RPC.

Glad you got it to work.