Search Unity

Resolved Problem with two box colliders

Discussion in 'Visual Scripting' started by Tinniman, Jul 3, 2022.

  1. Tinniman

    Tinniman

    Joined:
    Dec 14, 2020
    Posts:
    49
    Hi.
    This thing is bugging me.
    I have an enemy. This enemy must die by a bullet so I have box collider set to trigger a bullet entering and then remove this object. Works fine.
    I have made several efforts to have this code as a child but then it will only remove the child. Understandable.

    The issue is that I need the box collider to be different for moving the enemy when player comes near. This must be a much bigger collider. My problem is that if I make a new collider ( have two colliders), unity does not know when to trigger each of them.
    I have tried to add move node to child but that does not work.

    How do I fix this problem?
    Is there a way for Unity to understand which collider to react under same game object?

    This occur as a problem for me when using stuff that needs to be set for parent and cannot be on child.

    Hope anyone have a solution.
     
  2. Tinniman

    Tinniman

    Joined:
    Dec 14, 2020
    Posts:
    49
    I managed to fix this. Instead of setting the remove to this it just set it to the parent. Beginner mistake.
     
  3. munchmo

    munchmo

    Joined:
    May 20, 2019
    Posts:
    85
    Another option you can use is to have different types of colliders that do different things, circle collider does thing A, box collider does thing B, and so on.
     
  4. Tinniman

    Tinniman

    Joined:
    Dec 14, 2020
    Posts:
    49
    But will unity understand when to use the different colliders when you cannot set collider by name?
     
  5. munchmo

    munchmo

    Joined:
    May 20, 2019
    Posts:
    85
    Yes, because you can differentiate between types of colliders in your script. You have to build your own checks for it, but you can absolutely differentiate between a a box collider and a circle collider. It is also possible to actually assign a specific collider (if you've got two identical collider types on the same object) to a variable and use that to check if that's the one calling the collision.
     
  6. Tinniman

    Tinniman

    Joined:
    Dec 14, 2020
    Posts:
    49
    The variable solution I think I can do but If I need to make a script then I am lost. Trying to hoover my way with only visual scripting as normal scripting makes my brain pop;)