-life IF collision with block

0 favourites
  • 9 posts
From the Asset Store
Physics Block Puzzle game template for Construct 3
  • i am working on some stuff and i cant figure out how to implement the following.

    the game has a ground where the player walks on wich is grey . there are red sprites sometimes. when player is on collision with red block = -life (1)

    but nothing happens.

    any tips?

    screenshots :


  • EDIT = i now made a detector sprite and made it to lay 2 pixels over the ground. then the substraction of life works BUT it substracts ALL lifes not one ..

  • This is my event system for doing life system


    Simple = greenblock = +1 life

    Red block = -1 life

    but all this does is restarting the layout when i touch a red block

  • What is the default value of 'lifes' set to?

    Posting a .capx would help a lot.

  • try this:

    Add new globel Variable namend Is_hit from type Number = 0

    Event (Condition)                    Action

    player is overlapping red sprite --> Substract 1 from Lifes

    (Is_hit = 0)                         Set Is_hit = 1

    (Lives >=0)                          wait 0.5 seconds

                                        Set Is_hit = 0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I was thinking that too, it could just be draining all the lives when overlapping once as there's nothing to stop it detecting. Would have to see the .capx to make sure though.

  • Always remember how events work : events are tested EVERY tick, and also executed EVERY tick when true.

    In your example, at 60 FPS, your "life" value ends at -60 at the end of 1 second of collision.

    Either use a "Trigger once while true" condition, or prefer using a trigger condition "On collision". Or add other conditions to precisely time when the action of substracting is to happen.

    I wouldn't use wait actions as it might end up in unwanted behavior, and will only stack those actions as explained in this tutorial.

  • Add Trigger once while true subevent to both events and move the +1 and -1 actions there.

  • i solved it with your help thanks :)

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