Search Unity

Boxcast vs triggers

Discussion in 'Scripting' started by Siro13, Sep 4, 2020.

  1. Siro13

    Siro13

    Joined:
    Jun 30, 2014
    Posts:
    33
    Hi,
    I'm trying to implement the Dash ability on my character.
    Each time I press the button Dash, the character jumps forward 3 units.
    To keep him from going through walls and to detect the presence of enemies, I used a boxcast. The problem is that I can't see it in editor, like a Debug.DrawRay.
    Then I was wondering if it was not the same thing to use a box collider as a trigger, put as a child of the character, moved a little forward so it can trigger an event every time it collides with something.
    What do you think? Is it a possible alternative to the Boxcast?
    Thank you
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,914
  3. Siro13

    Siro13

    Joined:
    Jun 30, 2014
    Posts:
    33
    Ok.
    Yes I had seen the example and I was able to replicate it in Bolt, using on gizmos event.
    It made me struggle but I succeeded.
    However if you say that Boxcast is better, I trust you!
    Thank you
     
  4. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    If efficient mean performance you should profile, else you should try both anyway, I always a have a unity project to test throw away idea without messing teh main project.
     
    Terraya likes this.
  5. Siro13

    Siro13

    Joined:
    Jun 30, 2014
    Posts:
    33
    Yeah I am full of projects like this on my PC :p