Search Unity

Question objects overlap condition question

Discussion in 'Visual Scripting' started by MMokhtar89, Oct 24, 2022.

  1. MMokhtar89

    MMokhtar89

    Joined:
    Aug 4, 2022
    Posts:
    7
    Hi,
    I`m totally new in the built-in unity virtual scripting.

    all I need to know how can I add "if" condition when 2 objects overlapped some events happen like message appear to the player and another object appears.

    I need your help to know how do that, or from where to start.

    thanks in advance.
     
  2. MMokhtar89

    MMokhtar89

    Joined:
    Aug 4, 2022
    Posts:
    7
    I reached something.
    using "BoundsIntersect" and "If" condition, but it's always act like "ture", even the 2 objects not intersected.
    i don`t really understand what is the "bounds", and how can i add it to the game object.
    any help ?
    thanks in advance
     
  3. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    167
    If you use normal unity collision component set as triggers, you will be able to react to "On Trigger Enter" events nodes in graphs, which is basically an intersection of objects with collisions and rigid body.
     
    MMokhtar89 and REDACT3D_ like this.
  4. MMokhtar89

    MMokhtar89

    Joined:
    Aug 4, 2022
    Posts:
    7
    Great Thank you,

    but the "On Trigger Enter" nodes have only one input to add one game object, how can i add the two game objects whenever they intersect the new action begins.
     
    REDACT3D_ likes this.
  5. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    167
    So many ways, to accomplish the task.

    OptionA
    1- You can add a script with the on trigger enter event directly on the object that you want to trigger the event when let's say a player enter in the volume.
    2- This object could validate that the other object that went inside of its volume was the player by looking at a tag, a direct reference, it could only trigger when the layer collision matrix is good for both objects, ... .

    OptionB
    1- Your player could be the one with the collision script validating the type of trigger it is entering.
    2- It could trigger actions and make your mechanics happen when those conditions are met.

    It will mostly depend on how you want to structure your data, all options will come with some sort of challenges.
     
    MMokhtar89 and REDACT3D_ like this.
  6. REDACT3D_

    REDACT3D_

    Joined:
    Nov 8, 2020
    Posts:
    222
    yeah, the issue always is not knowing all of the ways you "can" do stuff until you kinda test and do em'. Sort of like finding your favorite flavor of iced creme. Gotta check em all but you may have some idea that perhaps the dirt flavor may not be what you're looking for. but maybe you're playing a joke on some guy. See the context.

    For example, I like to use Tags to distinguish what kind of triggers i'm looking for because it seems to plug into the rest of my code well.

    I use this so often that it may as well be a subgraph that i save.
    not normally offset like that but trying to show the Get Game Object is plugged into 2 things
    Capture.PNG



    Then this hooked onto a game object with the tag would just print the value to console.
    would use it in a damage calculation if real
    Capture2.PNG
     
    Last edited: Oct 27, 2022
    MMokhtar89 likes this.
  7. MMokhtar89

    MMokhtar89

    Joined:
    Aug 4, 2022
    Posts:
    7
    Thank you very much
    Can you just explain the option A much more, what is the exact nodes i need to use.
    thanks in advance
     
  8. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    167
    For the option A, it look like what @REDACT3D_ is showing.
     
    MMokhtar89 and REDACT3D_ like this.
  9. MMokhtar89

    MMokhtar89

    Joined:
    Aug 4, 2022
    Posts:
    7
    Thnak you very very much
     
  10. MMokhtar89

    MMokhtar89

    Joined:
    Aug 4, 2022
    Posts:
    7
    Hi guys,
    first thing thanks you for the great help.
    I understand the methods you mentioned above, and it's worked with me, but
    I am facing now another issue for the method, im using plugin to convert mesh to liquid (OBI plugin).
    i have to disable mesh render to just keep the liquid generated by the obi plugin.
    when i am using the "on trigger enter" and "compare tag" method, the tag just reeded from the mesh itself not from the liquid assigned to it by the plugin.

    all i need to reach is when the liquid touch another liquid event start.

    now I have to drag the mesh itself to touch the other mesh then the event start, not the liquids.

    any ideas ?

    thanks in advance
     
  11. MMokhtar89

    MMokhtar89

    Joined:
    Aug 4, 2022
    Posts:
    7
    Any Help ?