TOUR
PRICING
HELP
Stencylpedia
Blocks Guide
Sample Games
Developer Center
FORUMS
CHAT
#MADEINSTENCYL
EDUCATION
SIGN IN
×
Welcome back!
Username or E-mail
Password
(
Forgot?
)
C
OMMUNITY
Home
Issue Tracker
Inbox [0]
New Posts
New Replies
Search
Stencyl Community
→
Stencyl
→
Ask a Question
→
Health
Pages:
1
2
Health
Lingesh7
Posts: 54
November 14, 2012, 09:06:51 am
I have made a behaviour for health. (pls see pic) The problem is that when it collides with an enemy the hp instead of decreasing by 1 it just directly goes to 0. I also made a text behaviour for the scene to display the hp. When the scene is loaded it shows 10 but once it collides with an enemy it directly changes to 0. Is there any way to fix this? (I know about the Health behaviour on forge but it is too complicated and i dont understand much of it. So i want to make my own) Pls help. If there is no way out (99% impossible) can someone simplify the health behaviour and explain it to me. Thanks in advance
PhilIrby
Posts: 545
November 14, 2012, 09:22:53 am
I would suspect you are having multiple collisions with the enemy. Do a forum search for this and you will find a number of suggestions to prevent this.
dtrungle
Posts: 1938
November 14, 2012, 09:35:43 am
---
When self hits enemy
If canBeHit == true
set canBeHit to false
set HP to (HP - 1)
set delayFlag to true
End
---
---
When updating
If delayFlag == true
-set delayFlag to false
Do after 0.1 seconds
-set delayCounter to (delayCounter + 1)
If delayCounter >= 10
-set delayCounter to 0
-set canBeHit to true
Otherwise
-set delayFlag to true
End
End
---
Defaults
canBeHit == true
delayFlag == false
delayCounter == 0
Also, if your collision box has multiple boxes, this might not work. Test it out and let us know.
Lingesh7
Posts: 54
November 15, 2012, 02:51:35 am
It works but as PhilIrby said i am having multiple collisions with it-if I just stay there the hp goes like 9,8,7,6,...0 and then it dies. How can I solve this multiple collision? (also in the end of your when updating i added if player hp<=0 kill self otherwise the hp went on to minus)Main question how do i solve multiple collisions
chrizt
Posts: 345
November 15, 2012, 03:18:19 am
its not multiple collision. the collision block checking for collision every frame i assume. actually it was decreasing by 1 like u want, but i went too fast. try to put timer block in the collision block
need help with behavior? game design? graphic design? just contact me
skype : christian.atin
email :
christianatin27@gmail.com
Lingesh7
Posts: 54
November 15, 2012, 03:35:36 am
Using the same behaviour as dtrungle said, may i know where the timer for the collision block must be put?
chrizt
Posts: 345
November 15, 2012, 05:18:39 am
begin from the outer block collision>timer>set hp -1
need help with behavior? game design? graphic design? just contact me
skype : christian.atin
email :
christianatin27@gmail.com
Lingesh7
Posts: 54
November 15, 2012, 06:12:17 am
Sorry I dont understand much
Can you please make a picture of where the timer will be placed
Again thanks in advance
Lingesh7
Posts: 54
November 15, 2012, 06:12:46 am
A snapshot of the behaviour is what i meant
Innes
Posts: 1960
November 15, 2012, 06:51:06 am
There's an entry in my blog that explains some of the options to solve this problem...
http://www.thestencylblog.com/2012/06/16/stencyl-events-do-please/
« Last Edit: November 16, 2020, 10:58:50 pm by Justin »
Visit
www.TheStencylBook.com
- the only published book for learning Stencyl.
Lingesh7
Posts: 54
November 15, 2012, 07:41:27 am
Thanks All! Just one last question. The behaviour I (see pic) made is working. Will it have any problems later on? Or do i have to follow dtrungle's method. If I have to follow his method where exactly do i place the do after n seconds block?
dtrungle
Posts: 1938
November 15, 2012, 07:55:31 am
What you have there seems fine. Your behavior will allow your main actor to be damaged once every second.
Lingesh7
Posts: 54
November 15, 2012, 08:04:12 am
A very small problem. I have levels for my game and when I go to the next level, the HP resets back to 10. How do i continue with the same HP?
dtrungle
Posts: 1938
November 15, 2012, 08:57:18 am
Remove the 'when created' event, the thing that sets HP to 10. Go into game settings and look for it in GA, set the initial value to 10 there.
chrizt
Posts: 345
November 15, 2012, 03:57:07 pm
you need to set up a game attribute for that. any local attribute will reset its value once u leave scene/reload while Game attribute will store the value till you close the game
need help with behavior? game design? graphic design? just contact me
skype : christian.atin
email :
christianatin27@gmail.com
Pages:
1
2