Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: hoyoyo80 on October 10, 2018, 04:29:45 AM

Title: Health System - deduct one live but once per hit
Post by: hoyoyo80 on October 10, 2018, 04:29:45 AM
Hi all,

Im working on health deduction. Ive set when player attack action hit an enemies,it will deduct one life(using Integer)

But when ive set the deduct event to finished and move to non deductive event, that one hit deduct a few numbers.

How to deduct once per hit?

Thanks
Title: Re: Health System - deduct one live but once per hit
Post by: djaydino on October 10, 2018, 04:59:00 AM
Hi.
It is very depending on your setup so if you could show some images or video from your setup :)

A possibility is that you will need to use a next frame event. somewhere in between
Title: Re: Health System - deduct one live but once per hit
Post by: Thore on October 10, 2018, 04:29:24 PM
Hi all,

Im working on health deduction. Ive set when player attack action hit an enemies,it will deduct one life(using Integer)

But when ive set the deduct event to finished and move to non deductive event, that one hit deduct a few numbers.

How to deduct once per hit?

Thanks

Could it be that the event is triggered multiple times? To find out, you can switch on the counter how often states where triggered (I think that‘s in preferenes, or in the debug mode). Another pitfall is that the formula values aren‘t nulled and refreshed each new run, i.e. you accidentially operate with values left over from previous runs, and they add up.
Title: Re: Health System - deduct one live but once per hit
Post by: hoyoyo80 on October 11, 2018, 10:35:57 PM
Ive tried but still i deduct a lot instead of once
The process:
1.My sword hit box(a trigger) check the enemy hit(CheckHit)
2.If it triggered by the enemy, it will send a Global Event to the enemy to deduct its lives.(Send Hit)
3.The enemy received the global event and deduct 1 from its lives(GetHit)

Thanks

Title: Re: Health System - deduct one live but once per hit
Post by: djaydino on October 12, 2018, 12:22:28 AM
Hi.
You can remove the next frame events

You can try to set on trigger enter instead of on trigger stay.

Have a ontrigger exit in the loop.

Your setup now will trigger multiple times
As long it is inside the collider.  :)
Title: Re: Health System - deduct one live but once per hit
Post by: hoyoyo80 on October 12, 2018, 01:28:48 AM
Thanks!!!

That quite a simple fix but i dont know it. Working perfect now!!!

Thanks again!!!
Title: Re: Health System - deduct one live but once per hit
Post by: djaydino on October 14, 2018, 08:26:24 AM
Quote
Hi all...

In other topic im asking about deducting health. But now my prefabs is ready to get hit and die. But i found that when i use more that one prefabs, the deducting sometime work and sometimes dont.

What could be the problem.
Thanks

Can you show the fsm on the prefab?
Are you using global variables?
How are you applying damage to the enemies?