Check If No Collision?

Discussion in 'How Can I...?' started by Colton Crawford, Dec 29, 2021.

  1. Colton Crawford

    Colton Crawford Boxer

    Joined:
    Dec 29, 2021
    Messages:
    2
    Likes Received:
    0
    Hello,
    I'm trying to make a simple box launching game where boxes have to be placed in the proper areas to complete the level. I've got trigger objects on the correct locations that check for a collision with a box, and if there is one, adds a point.
    However, if that box gets removed from the location, I want to subtract a point.
    Is there a way to check when there isn't a collision? I've tried using the Invert Signal node after an If Collide node, but that still requires there to be a collision in the first place. The basic logic I'm trying to make is this:
    - If collision > Check if added point > If not, add point
    - If No collision > Check if removed point > if not, remove point
    I have some Javascript experience so I'm fine with writing a bit of script if I have to, I just can't figure out how to make the target object actively check if a collision is currently happening, rather than just having something trigger in the event of a collision. I wish the If Collision node was editable, I feel like it would be pretty easy to reverse the collision check in-code, but I can't figure out how to make it happen using the node system.
    I hope this makes sense! Any help would be much appreciated!
     
  2. Colton Crawford

    Colton Crawford Boxer

    Joined:
    Dec 29, 2021
    Messages:
    2
    Likes Received:
    0
    Ok I actually got very close. After the first collision when the point is added, I add a point and set a timer. The timer waits 2 seconds then removes a point, and checks for another collision, and if found, adds a point. This way whenever the timer goes off, a point is removed, and if there is a collision, another one is added.
    The problem now is that the "If Collide" node only checks for a collision one time. So on the second loop, the point is removed, but not re-added, even if there is a collision. I added a log output to the "If Collide", and it only sends the log message on the first loop, so I'm pretty sure once that node gets triggered it just basically dies.
    Is there a way for me to reset the "If Collision" node so it checks for a collision every time it receives a signal from the timer? Or have the node create a copy of itself on each loop, or something? I really wish that damn If Collide code was editable! Not even editable, just to be able to see the code would be a huge help in understanding how to manipulate that node I think.
    Thanks again for the help!
     
  3. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    I will share a node tomorrow for this.

    Btw you can create custom node similar to if collide node just take a look at buildbox api on if collide node.
     
  4. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    If collide do both checks when collision enter and exit
     
  5. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84

    Attached Files:

Share This Page