Announcement

Collapse
No announcement yet.

C++ won't compile after creating class with TriggerBox as parent.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    C++ won't compile after creating class with TriggerBox as parent.

    I'm not sure if this is something I shouldn't be doing.

    But when I create a new class with TriggerBox as the parent in the Editor, when I switch back to my C++ won't compile and will give errors in the TriggerBase.h files and such.

    Is this a bug or am I doing something wrong?

    Thanks all
    Last edited by comeradealexi; 09-30-2014, 03:36 PM.

    #2
    I've probably mucked around with this for longer than I should - only because I kept modify engine code by accident and causing a full recompile three times!

    Yup, I get the compile error. ->

    Error 1 error C2504: 'ATriggerBase' : base class undefined G:\Depot\UnrealEngine\4.4\Engine\Source\Runtime\Engine\Classes\Engine\TriggerBox.h
    You can get around it initially by inlcuding #include "Engine/TriggerBox.h and TriggerBase.h" but then it complains about being unable to find the implementation of TriggerBox::EditorApplyScale.

    This function is implemented in TriggerActors.cpp and I can't see how it's exposed.

    Now, TriggerBase.h has this comment:

    /**
    * An actor used to generate collision events (begin/end overlap) as inputs into the scripting system.
    */
    Which leads me to believe this is strictly for use in Blueprints.

    Could you use a UBoxComponent instead and implement functions for OnComponentBeginOverlap and OnComponentEndOverlap ?

    Code:
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = VASA)
    TSubobjectPtr<UBoxComponent> DoorCollision;
    DoorCollision->OnComponentBeginOverlap.AddDynamic(this, &AVSDoor::OnBeginOverlapDoorCollision);
    DoorCollision->OnComponentEndOverlap.AddDynamic(this, &AVSDoor::OnEndOverlapDoorCollision);

    Comment


      #3
      Thanks for the reply!

      I was able to inherit from trigger in UE3 with unrealscript which is why I was perplexed.

      Glad it wasn't just me. Yeah I've taken your advice and am using the box component instead Thanks for the code at the bottom too! I was going to link the overlap functions in Blueprints but your way seems a lot better!

      Comment


        #4
        Cool
        I'm guessing creating classes via the editor should at least warn you.

        You could also use a UShapeCompnent so you're not restricted to a box - just like TriggerBase does
        https://github.com/EpicGames/UnrealE...ggerBase.h#L20

        I'm not sure I'm doing things The Right Way but I'm more comfortable in C++ than in Blueprints. So I adorn those callbacks with BlueprintNativeEvent and provide the default implementation in C++ but allow them to be overridden by modders.

        Comment


          #5
          There is also an ATriggerVolume that you can extend from. It seems to be the same thing as TriggerBox.

          Comment

          Working...
          X