UE4 C++ Inventory : Pickup

Sdílet
Vložit
  • čas přidán 11. 09. 2024
  • This is the first part on an Unreal Engine 4 (UE4 version 4.15) C++ Inventory tutorial in which I focus on implementing the pickup and collecting logic of the actor.
    See my social profiles here
    G+: plus.google.co...
    Twitter: / jayanamgames
    Facebook: / jayanamgames
    Patreon: / jayanam
    Indiegogo: / jayanamgames
    Production Music courtesy of Epidemic Sound: www.epidemicsou...

Komentáře • 48

  • @MPatrickDearman
    @MPatrickDearman Před 7 lety +14

    I'm using 4.16.1
    Had to add #include "Components/BoxComponent.h" before the #include "PickupActor.generated.h" line in PickupActor.h for this to work.
    Great tutorials though. They are helping me a lot.

    • @JayAnAm
      @JayAnAm  Před 7 lety +1

      Hi and thx. Well, what you can also do is to define the BoxCollision as UShapeComponent then you don't need to include, the internal cast to BoxCollision is done in the implementation when creating the component.

    • @MPatrickDearman
      @MPatrickDearman Před 7 lety +1

      I'm assuming what you mean is to use "UShapeComponent* BoxCollider;" instead of "UBoxComponent..."
      This did not work either, unless I misunderstood what you meant.

    • @JayAnAm
      @JayAnAm  Před 7 lety

      Yes, like this, then you just have to add CoreMinimal.h You can also check my upload here for a Cube that uses this: www.patreon.com/posts/12138285 C++ code for the actor is in the posting's text

    • @MPatrickDearman
      @MPatrickDearman Před 7 lety

      Jay AnAm CoreMinimal is there by default yet declaring BoxCollider as UShapeComoonent still does not work unless it is Included as I had to do with UBoxComponent.
      It's really aggravating how quickly engine source gets updated and breaks all of these awesome tutorials. Oh well I guess... I'm still learning a lot.

    • @robertbereza6335
      @robertbereza6335 Před 7 lety

      Had the same problem, and I also had to include "Engine.h" in order to use GEngine->AddOnScreenDebugMessage()

  • @michaelivanov1605
    @michaelivanov1605 Před 4 lety +2

    Хороший урок! У кого не работает это "Box->bGenerateOverlapEvents = true;", попробуйте "Box->SetGenerateOverlapEvents(true);".

  • @pollovaldes
    @pollovaldes Před 4 lety +3

    If you are using a recent version of UE4, instead of writing "bGenerateOverlapEvents = true" write "SetGenerateOverlapEvents(true)"

  • @FreemanTraceur
    @FreemanTraceur Před 5 lety

    For anyone reading this, if you want to copy the signature of overlapbegin (or any other built-in event) you can actually find it from their respective header files included with the unreal dev tools for VS. In this case the header file is, PrimitiveComponent.h , you don't have to include this file in the cpp file. Just open the header file and find the function, copy the signature, there will be a bunch of extra commas separating the variable names from the data types, so you'll have to get rid of those and then just do whatever you want to.
    This is extremely useful because, the signatures of events and functions may get changed and this way you'll get the required signature.

  • @tsubarider13
    @tsubarider13 Před 5 lety

    Great tutorial dude! Didn't understand how to implement overlap events before I watched this video. Thanks :)

  • @BauTekIndustries
    @BauTekIndustries Před 4 lety

    These videos are great, thanks for putting them together! I'm going through these with UE version 4.24 and there are a couple of changes they must've made that required the following revisions:
    1. The 'this->BoxCollider->OnComponentBeginOverlap.AddDynamic' had to be moved to APickupActor::BeginPlay() before Super::BeginPlay() is called
    2. I had to add '#include "Engine/Engine.h"' into PickupActor.cpp to access anything in GEngine
    3. As other mentioned, had to add '#include "Components/BoxComponent.h"' into PickupActor.h
    Thanks for putting these tutorials together, looking forward to working through the rest of the series!

  • @GPTDavid
    @GPTDavid Před 7 lety +2

    Your videos are just fantastic.. You need a lot more subscribers, a lot more likes.
    Great job!

  • @user-wn6wx1jj7x
    @user-wn6wx1jj7x Před 2 lety

    Thank you very much from China;

  • @andrew.r.lukasik
    @andrew.r.lukasik Před 3 lety

    Thanks!

  • @nipunmarak5805
    @nipunmarak5805 Před 5 lety +1

    I added #include "Cpomponents/UBoxComponent.h" . But still it's not working and showing error C2248: 'UPrimitiveComponent::bGenerateOverlapEvents': cannot access private member declared in class 'UPrimitiveComponent'
    And I'm using version 4.20.3
    What can i do?

    • @aliang8373
      @aliang8373 Před 5 lety +2

      i use 'this->BoxCollider->SetGenerateOverlapEvents(true)' to replace;

    • @nipunmarak5805
      @nipunmarak5805 Před 5 lety

      ​Great man...
      It works.
      Thank you

    • @corygaga5930
      @corygaga5930 Před 4 lety

      @@aliang8373 thank you,I met the same problem,finally found you, otherwise i will give up

  • @MrPain4Blood
    @MrPain4Blood Před 7 lety +2

    Great tutorial! Make more UE4 C++ videos!

  • @stompeee
    @stompeee Před 7 lety +2

    What advantage does creating OnOverlapBegin have, rather than just using OnActorOverlapBegin?

    • @FreemanTraceur
      @FreemanTraceur Před 5 lety

      I know I'm late, but creating OnOverlapBegin allows you to do something specific for specific component overlaps, while the OnActorOverlapBegin will consider the entire actor. It'll work here but not for complex actors, with various components.

  • @tulczi
    @tulczi Před 6 lety +1

    Very nice video! Kind regards for such great explanation.

  • @bertani6134
    @bertani6134 Před 3 lety

    Amazing!!!!!!!!!!!!

  • @wayzeranime8210
    @wayzeranime8210 Před 7 lety +1

    I am always waiting for more from you 😉😉

    • @JayAnAm
      @JayAnAm  Před 7 lety +1

      :-) thx a lot, like my videos if you do and if you have any special wishes let me know.

    • @wayzeranime8210
      @wayzeranime8210 Před 7 lety

      Jay AnAm OK I will start my first game i the next it is an endless runner game do you mind if you explain better the random terrain generation and the work of the nodes included or just make it in c++ , thanks 😉😉😀.

    • @JayAnAm
      @JayAnAm  Před 7 lety +1

      ok, thx will put it to my list.

    • @wayzeranime8210
      @wayzeranime8210 Před 7 lety

      Jay AnAm I'm waiting for your notification 😅😅

  • @ReubenAStern
    @ReubenAStern Před 4 lety

    Is it just me or has the Collision been changed as of UE4.24? I think they may have done this to get the chaos thing to work.

  • @SlumpogMillionaire
    @SlumpogMillionaire Před 7 lety

    Just tried doing this without any tutorials... found out the hard way that you need the UFUNCTION() macro above the declaration for the overlap to work.
    This drove me nuts for over an hour because not only does the trigger overlap not work without the macro, but it also doesn't give any compile errors or warnings when compiling.

  • @jobchen5019
    @jobchen5019 Před 6 lety

    That's great!!!!!!!but I have a question.......why my code is follow your video,【FString pickup = FString::Printf(TEXT("Picked up: %s"), *GetName());
    GEngine->AddOnScreenDebugMessage(1, 5, FColor::Red, pickup);】....this is successed for the code.. and when I push "play" and get the object after.....it is not display any "ObjectName string" in viewport ....

  • @tiptopboy88
    @tiptopboy88 Před 7 lety +2

    thanks , plz determine UE4's version of each C++ tutorial.

    • @JayAnAm
      @JayAnAm  Před 7 lety +3

      Ok, you are right, will add it. This one is 4.15.

  • @GameDevBeat
    @GameDevBeat Před 6 lety

    i have used both Unreal and unity and currently my project in unreal with blueprint but i see C# way much more simpler than C++ to do all this... in Unity the collision > and check for tags or what ever

  • @s-c-iulian
    @s-c-iulian Před 7 lety +1

    1:31 does it have something like that ? :D

    • @JayAnAm
      @JayAnAm  Před 7 lety

      Of course, and a good one: docs.unrealengine.com/latest/INT/API/index.html

  • @dansuricato6828
    @dansuricato6828 Před 7 lety

    Hi, I'm wondering ...how could an Actor be NULL?

    • @JayAnAm
      @JayAnAm  Před 7 lety

      If you declare it as variable but don't create and assign it.

  • @IJUSTLOVEPC
    @IJUSTLOVEPC Před 6 lety

    Hello first of all great vids but i have some questions.
    First of all why do we make all UStaticMesh, AActor pointers? I know what a pointer is but i have a hard time understanding when to use them in ue4 c++ code.
    And when we 'AddDynamic(this, &APickUpActor::OnActorBeginOverlap)'
    Why did we put a ampersand (adress of) operator? I know we use the '&' before out parameters. Example
    Int32 SizeX, SizeY
    GetViewPortSize (&SizeX, &SizeY)
    I Know we get the adress to the int32 so when the method find the viewport size it finds the adress of the int32 and modifes its values instead of creating a copy that gets lost when out of scope.
    But i do not underatand why we use them in AddDynamic or when to use '&' more than in out parameters?

    • @JayAnAm
      @JayAnAm  Před 6 lety

      Hi, pointers are used here because we want to hold these objects on the heap, not on the stack. In AddDynamics the OnActorBeginOverlap is a function-pointer, in C# this is done with delegates, that's why you need the address of this method in memory.

    • @IJUSTLOVEPC
      @IJUSTLOVEPC Před 6 lety +1

      I Think i have got a grasp about why we use pointers. When we do "UStaticMesh* CubeMesh" the "UStaticMesh" is a class itself and instead of copying UStaticMesh class with "UStaticMesh CubeMesh", we just Point to it location in memory so it would be more efficient!
      Im kind of right, right?

    • @unrealper6284
      @unrealper6284 Před 4 lety

      want to know too