playMaker

Author Topic: Health System - deduct one live but once per hit  (Read 2213 times)

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Health System - deduct one live but once per hit
« 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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Health System - deduct one live but once per hit
« Reply #1 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

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Health System - deduct one live but once per hit
« Reply #2 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.

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: Health System - deduct one live but once per hit
« Reply #3 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


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Health System - deduct one live but once per hit
« Reply #4 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.  :)

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: Health System - deduct one live but once per hit
« Reply #5 on: October 12, 2018, 01:28:48 AM »
Thanks!!!

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

Thanks again!!!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Health System - deduct one live but once per hit
« Reply #6 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?