UE4 C++ Inventory : Pickup
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...
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.
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.
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.
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
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.
Had the same problem, and I also had to include "Engine.h" in order to use GEngine->AddOnScreenDebugMessage()
Хороший урок! У кого не работает это "Box->bGenerateOverlapEvents = true;", попробуйте "Box->SetGenerateOverlapEvents(true);".
If you are using a recent version of UE4, instead of writing "bGenerateOverlapEvents = true" write "SetGenerateOverlapEvents(true)"
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.
Great tutorial dude! Didn't understand how to implement overlap events before I watched this video. Thanks :)
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!
Your videos are just fantastic.. You need a lot more subscribers, a lot more likes.
Great job!
:-) Thank you!
Thank you very much from China;
Thanks!
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?
i use 'this->BoxCollider->SetGenerateOverlapEvents(true)' to replace;
Great man...
It works.
Thank you
@@aliang8373 thank you,I met the same problem,finally found you, otherwise i will give up
Great tutorial! Make more UE4 C++ videos!
Ok, I will!
What advantage does creating OnOverlapBegin have, rather than just using OnActorOverlapBegin?
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.
Very nice video! Kind regards for such great explanation.
Thx a lot!
Amazing!!!!!!!!!!!!
I am always waiting for more from you 😉😉
:-) thx a lot, like my videos if you do and if you have any special wishes let me know.
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 😉😉😀.
ok, thx will put it to my list.
Jay AnAm I'm waiting for your notification 😅😅
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.
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.
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 ....
thanks , plz determine UE4's version of each C++ tutorial.
Ok, you are right, will add it. This one is 4.15.
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
1:31 does it have something like that ? :D
Of course, and a good one: docs.unrealengine.com/latest/INT/API/index.html
Hi, I'm wondering ...how could an Actor be NULL?
If you declare it as variable but don't create and assign it.
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?
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.
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?
want to know too