Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Haserhud on February 21, 2020, 12:22:30 PM

Title: Strange Int Switch Issues when colliding with object in motion [SOLVED]
Post by: Haserhud on February 21, 2020, 12:22:30 PM
Hi all,

This is a weird one.

I have a Damage FSM set on objects, and I have a Health FSM set on my Player. The Damage FSM on objects affects player health by adding -1 to the global health variable I have set up, which in turn affects the player health FSM by using int switches.

Everything works great until I apply the damage-causing FSM to an object in motion (using the Move Towards action).

When the object is in motion and the player hits it, it's fine until it gets to the last heart. Once it gets to the last heart and they collide, the global variable for health goes crazy and rapidly decreases from 1 to negative hundreds, thousands, etc. And then the FSM for Health on my Player remains stuck on 1 health. I don't understand what the hell is going on here. I will supply the screenshots. I am highlighting where in the Health FSM it gets stuck.

Remember, this all works perfectly when the object the player collides with is not moving.
Title: Re: Strange Int Switch Issues when colliding with object in motion
Post by: Haserhud on February 21, 2020, 12:25:45 PM
Adding an extra screenshot to show what I have on my WaitForCollision state.
Title: Re: Strange Int Switch Issues when colliding with object in motion
Post by: Haserhud on February 21, 2020, 12:49:02 PM
Solved it.

Silly me. That final state of damage, I didn't have it going to another state after it was done. So it would sit on that state, adding -1 to the health variable every frame, which confused the health FSM and got it stuck.

I just told it to go to finished and then to a final state when done and it seems to work great now.
Title: Re: Strange Int Switch Issues when colliding with object in motion
Post by: djaydino on February 23, 2020, 10:27:07 AM
Hi.
I can see on 'Collision 3' that 'int add' is set to every frame.
This means that every frame it deduct 1.

also maybe its better to use a 'int compare' instead of switch
Title: Re: Strange Int Switch Issues when colliding with object in motion
Post by: Haserhud on February 28, 2020, 04:44:18 PM
Hi.
I can see on 'Collision 3' that 'int add' is set to every frame.
This means that every frame it deduct 1.

also maybe its better to use a 'int compare' instead of switch

Man, you've saved my butt so many times now  ;D

Thank you!