Invert “is Touched” Node?

Discussion in 'How Can I...?' started by OceSetThisCannotBeChanged, Feb 9, 2020.

  1. OceSetThisCannotBeChanged

    OceSetThisCannotBeChanged Boxer

    Joined:
    Sep 6, 2018
    Messages:
    21
    Likes Received:
    2
    Hey guys,
    in my build I intend an object to check collision every x seconds (via send/receive node from a different entity) and give a true/enabled signal if no collision is detected. The problem with using a invert signal node is that in order for it to send a true signal the collision first has to take place (collision true gets inverted to false) and then the object to collide with has to be moved out of the hitbox (collision false gets inverted to true). However I want it to send a true signal even if it hasn’t yet collided with the object in question. Not sure if this can be solved with code since the ‘if collide’ node can’t be edited. Any Ideas?
    Thanks in advance.
     
  2. jmp909

    jmp909 Boxer

    Joined:
    Feb 2, 2020
    Messages:
    28
    Likes Received:
    4
    can you be a bit more specific about each object and what it is doing please? Specific examples stating which object is sending, which is receiving, what happens when the true signal (not colliding) is received etc

    I'm wondering if this is the best architecture though. Constantly polling when there's no collisions is just slowing your game down unnecessarily surely?

    Also what do you want to do if the collision has begun & ended before the timer has even run the next check? do you want to know that there *was* a collision between the 2 timer calls?

    Again it's easier if we know what each object is using this data for
     
    Last edited: Feb 10, 2020
  3. OceSetThisCannotBeChanged

    OceSetThisCannotBeChanged Boxer

    Joined:
    Sep 6, 2018
    Messages:
    21
    Likes Received:
    2
    This is my setup:
    Screenshot 2020-02-11 at 10.27.09.png
    I use a send/receive node rather than a timer node because there this object will be present many times in the scene and I want the timing to be consistent. Essentially I offset the collision box of the 'If collide' node 2 units down on the y axis and every time it the timer goes of (every 1 sec for example) it enables the if collide node for a split second and checks if something is exactly below it. If not the if collide node sends a true and it spawns itself right below it.

    I thought of a setup like this:
    Screenshot 2020-02-11 at 10.54.58.png
    It involves a custom node (which I have no idea how to code) that only lets a signal pass through if it is 'enabled'. In the settings you would be able to choose weather a true or false command enabled the node and stays enabled until given the other command. To clarify the node doesn't do any thing if it gets a signal on the bottom left connector, it only enables/ disables it which in turn allows a signal to pass through the top two connectors or not. Can anyone do this? Does anyone know a good gig on fiverr for custom Buildbox Nodes?
     
    Last edited: Feb 11, 2020
  4. jmp909

    jmp909 Boxer

    Joined:
    Feb 2, 2020
    Messages:
    28
    Likes Received:
    4
    1) i don't see a timer or send nodes. I assume "Check if there is a collision" is a Receiver though. What is sending the signal?

    2) "it spawns itself right below it" makes no sense.. again you are not explaining with actual examples you're using "it" to refer to several things, which is therefore ambiguous

    I am assuming though it is meant to be a spawner object (say "BlobSpawner") that will spawn something (say "Blob") every X seconds if nothing is in the way below it?

    3) I don't understand how your logic relates to that requirement though. I think what you're trying to say is

    Timer Object:
    * every X seconds Send "Request Spawn" message

    Spawner Object
    * when "Request Spawn" is received, check if something is currently colliding with it below.
    * If nothing is colliding, Spawn an object (this behaviour can also be inverted though in the inspector.. ie spawn if something *is* colliding)

    4) Your variables on your script are confusing not ticking "Enabled by default" is the same as "Disabled by default".. therefore there is no need for a "Disabled by default" option. Just don't tick the "Enabled by default" one. Same for "Enable if true" vs "Enable is false".. just have one and tick it or not.
     
  5. jmp909

    jmp909 Boxer

    Joined:
    Feb 2, 2020
    Messages:
    28
    Likes Received:
    4
    this might do what you need... I've not included the "Enable by default" etc.
     

    Attached Files:

  6. jmp909

    jmp909 Boxer

    Joined:
    Feb 2, 2020
    Messages:
    28
    Likes Received:
    4
    the condition can also be wrote as:
    Code:
    if(_colliding ^ !_spawnIfCollided)
    using XOR etc

    but it's easier to understand the original way
     
  7. OceSetThisCannotBeChanged

    OceSetThisCannotBeChanged Boxer

    Joined:
    Sep 6, 2018
    Messages:
    21
    Likes Received:
    2
    Sorry for keeping it vague but I really don’t want to give away the premise of the game. I now figured out another way to do what I intended to do. Thanks for your time!
     
  8. jmp909

    jmp909 Boxer

    Joined:
    Feb 2, 2020
    Messages:
    28
    Likes Received:
    4
    I just meant referring to specific objects in abstract terms such as "BlobSpawner" and "Blob" but anyway, glad you got something working.

    Care to share your solution? I couldn't think of another way to do it without code. I looked at Switch & State Machine but none seem to have a way of combining boolean logic without script
     
  9. jmp909

    jmp909 Boxer

    Joined:
    Feb 2, 2020
    Messages:
    28
    Likes Received:
    4
    this works (Variable Save / Load) .. I don't know what the performance is like though in terms of how it saves the variable. Whether's its just in memory or to disk
     

    Attached Files:

  10. OceSetThisCannotBeChanged

    OceSetThisCannotBeChanged Boxer

    Joined:
    Sep 6, 2018
    Messages:
    21
    Likes Received:
    2
    My solution is to have all objects already in place in all possible positions. The 3d object node activates when appropriate. So basically they are invisible unless activated. Performance is good on my 2018 ipad pro, on my iphone6 not so much. So I guess I'll have to do some optimisation.
     
  11. jmp909

    jmp909 Boxer

    Joined:
    Feb 2, 2020
    Messages:
    28
    Likes Received:
    4
    that means all your nodes will be running even though the character can't be seen, which definitely isn't good for performance

    if you're taking that approach, i suggest maybe putting a State Machine that then turns everything on when needed? (see attached picture)

    did you check my examples above though? Saving and Loading a variable to store whether it's colliding or not? It did what you needed, I can send you an example
     

    Attached Files:

    • fsm.png
      fsm.png
      File size:
      23.8 KB
      Views:
      15
  12. jmp909

    jmp909 Boxer

    Joined:
    Feb 2, 2020
    Messages:
    28
    Likes Received:
    4
    all Script nodes should also check if the Script is enabled, and exit the Update early if not. The Rotate node has an example of this, but you can implement like this... (replace the "In" pin in my picture with an "Enabled" pin)

    Code:
    let enabled = false;
    
    function update(dt){
    if(!enabled) return; // do nothing, we are not ready
    log("script!"); // only runs when node "enabled"
    }
    
    function signal(name, value){
      if(name == "Enabled") {
        enabled = value;
      }
    }
    
     

Share This Page