How do I Continue on collision detection

0 favourites
  • 4 posts
From the Asset Store
Detects any kind of ad blocker. Very easy implementation into already existing projects
  • Hi,

    I am having a small issue where I have a lake in which my character has to get over, but if he falls into the lake deduct x from his health.

    So I have set-up an on collision event so when the player collides with my set collision points it works fine and on the first collision 10 points are deducted from his health. However if I just leave the player idling in the lake or moving or whatever other than jumping out and coming back in, no more points get deducted.

    I also tried overlapping the lake object to see if this could help but this did not either.

    If I jump back in, the points get deducted then same again as above. so it seems that once the collision event has been done, it does not do it again. Is there anyway I can get the collision to keep being detected or is there a better way to handle this.






  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey thorntonp72,

    The "Collision" condition for objects "A" and "B" will only trigger when object "A" transitions from a state of not overlapping "B" to a state of overlapping "B".

    The "Overlapping" condition will be true whenever "A" overlaps "B". (e.g. If you put this condition in a top-level event by itself, it will run every tick.)

    Collision is a "triggered" condition, while Overlapping is a "true/false" condition. In fact the little green arrow just to the left of the collision condition is to indicate that it's "triggered" instead of "true/false". Triggered conditions don't get checked every tick, instead they just execute instantly when their criteria are met.

    (See the header "Events run top to bottom" in this article for more about the difference between the two condition types.)

    There are a few ways to get the continuous damage effect...

    Smooth damage over time

    You could have the lake deal a very small amount of damage every tick, (every frame-draw, about 60 times a second). This would cause the health to drain smoothly while in the lake. This is probably the simplest to program. You can also optionally use decimal damage values less than 1.0, and round the hp number when displaying total hp.

    Chunk damage every second

    You can have an event check every second to see if the player is overlapping the lake, and if so deal damage to the player. If you want the damage to come in chunks, this will do it, but this particular method is not such a good approach to chunk damage.

    If a player steps in the lake right after a 1-second-check, and the player gets out right before the next 1-second-check, they'll take no damage. Even if they don't get out, it could take nearly an entire second before they take damage, which could look weird.

    Chunk damage every second of exposure

    This is probably the more elegant way to deal chunk damage. You deal a chunk of damage when the player *Collides* (not overlaps) with the lake, and you start a 1-second timer, (using the timer behavior). When the timer triggers, you check to see if the player is still overlapping the lake, and if they are, you deal a chunk of damage, and start the time again.

    If a player jumps in the lake they will instantly take damage, and every second afterwards if they stay in the lake, that 1-second time will deal damage and reset, over and over.

  • Hi Fisholith,

    Thanks for the in-depth knowledge dump. This is very helpful. I will have a look at both the Smooth Damage option and the Chunk damage every second of exposure and see what I can come up with. Yes I think my review of event orders is required

    Thanks again!!!

  • No problem, glad to help out.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)