How do I make my collision loop?
I currently have this setup (.cpp):
This is successful in damaging my character every time I walk onto it, but it doesn't loop so if I stand on top of it I don't continue to take damage. I can't move this to the Tick class.
I tried adding a while loop, but it made my program crash:
Is there any way to make my collision tick so it can check every second if my character is colliding with it?
What you can do is to use a timer to try to inflict damage to a set of characters in the fire area every time it ticks. Every time a character enters the area (via OnComponentBeginOveralp) you add the character to this set, and every time a character exits the area you remove it from the set.
The additional codes would look something like this (please note that this code below is written from the top of my head and have not been tested, it's just to give you a rough idea of how it is done) :
There are of course a lot of additional things you can do with this kind of implementation, if you want to optimize the code you can play around with the timer handle on only run it when there's actually character in the area, you can tweak the damage rate to match the fire particle to give a bit of immersion to the game, etc.
answered Jul 19 '16 at 03:16 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here