C++ Collision and Delegates UE4 / Unreal Engine 4 C++
Vložit
- čas přidán 22. 06. 2019
- UE4 C++:
This playlist covers various aspects of working with C++ inside of the Unreal Engine.
This Video:
In this video, we cover the process of working with any collision events in Unreal C++. This video specifically looks at BeginOverlap events but the process and logic are the same for any other Overlap or even Hit events.
Links:
The beginning of this playlist: bit.ly/CPPOverviewUE4
Download projects from any complete tutorial series and more: github.com/DevEnabled?tab=rep...
Consider supporting the channel on Patreon: / devenabled
My First Pluralsight Course: app.pluralsight.com/library/c...
My Second Pluralsight Course: www.pluralsight.com/courses/u...
My Third Pluralsight Course: app.pluralsight.com/library/c...
Check out my Website: devenabled.com/
Twitter: / robbcreates
Sound Effects (BFXR): www.bfxr.net/
Get Affinity Designer: affinity.serif.com/en-gb/
Get Unreal: www.unrealengine.com/
Get Some great free assets here: www.gamedevmarket.net/ Gamedev.tv Courses - Affiliate Links:
Unreal C++ Developer: www.gamedev.tv/p/unreal-engin...
Unreal Multiplayer: www.gamedev.tv/p/unrealmultip...
Unreal Blueprints: www.gamedev.tv/p/unreal-bluep...
Blender Characters: www.gamedev.tv/p/blender-char...
In this video, we cover the process of working with any collision events in Unreal C++. This video specifically looks at BeginOverlap events but the process and logic are the same for any other Overlap or even Hit events.
You all probably dont give a damn but does any of you know of a tool to get back into an Instagram account??
I was dumb lost the password. I appreciate any tricks you can give me.
@King Logan Instablaster :)
@Lochlan Seth Thanks so much for your reply. I got to the site on google and I'm waiting for the hacking stuff now.
Takes quite some time so I will get back to you later when my account password hopefully is recovered.
@Lochlan Seth it did the trick and I actually got access to my account again. I am so happy!
Thanks so much you saved my ass :D
@King Logan No problem :)
Please keep these up man, great as always
The documentation has been updated and no longer contains the example code / signature referenced in the video, I looked around for another example but I couldn't find one easily so I just copied it out of the video if anyone else wants it:
OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
It's there docs.unrealengine.com/en-US/ProgrammingAndScripting/ClassCreation/CodeOnly/index.html
mvp
legend, thank you!
@@alexheuman3586 good looks
Excellent work!
Thanks for great tutorial
Another brilliant tutorial, thank you.
You're very welcome!
THANK YOU SO MUCH!!!
04:13 I can't find anything like this in documentation on the same page. Are they deleted it? What happened to this nice documentation?
It's there buddy in the C++ API. How are you gonna learn how to make games if you can't read and insist on insulting the documentation?
@@alexheuman3586 Look, I got the documentation website and only get this absolute shite: docs.unrealengine.com/en-US/API/Runtime/Engine/Components/UPrimitiveComponent/OnComponentBeginOverlap/index.html
Oh gosh, I've wasted so much time trying to understand why my delegate in constructor doesn't work. Thank you sooooo much!!! Awesome tutorial!
No worries, happy to help.
In AYTCharacterBase::OnOverlapBegin(), you will have a crash when colliding with an interactable object while not focusing on it. Make sure to check that "FocusedActor is equal to OtherActor" before calling Interface->Execute_OnInteract().
Why can I not find any example code in unreal's docs?
I really enjoy the way you explain complex physics ! I have been working as a software dev for a while and it ticks me a bit to find the optimal performance for programs/games. Why aren't we using the onHit since all we need to do is catch the event of the collision and make the grey cube disappear ? isn't the overlap kinda an overkill ? Thanks again for your content :D
Same complexity for different goals. Do you want your object to be physically blocked or stopped and return details? Use Hit. Do you want to just know when two things are in the same space but not necessarily move eachother out of the way, for example a checkpoint, use Overlap.
@@DevEnabled Watching your amazing tutorial also cleared that question for me :D czcams.com/video/KQgOqyYoHAs/video.html
First of all thanks for the video.
Secondly I would like to note how much I hate what they have done to the documentation. It's basically 100% useless now. The delegate signature isn't even available from the documentation anymore and I had to find it in the Source Code.
Please tell me how you can do cast without overlapped?
Thanks: it looks in 4.26 they fixed the issue about constructor.
Handy to know, thanks.
BP_Character's MeshComp should be set to all Overlap
BP_Character's CapsuleComponent should be set to Ignore Visibility and Block everything else.
BP_Interactable's Cube should be set to Block Visibility and Overlap everything else. You *don't* need to uncheck the "Do Collision Test" in BP_Character's SpringArmComp when you overlap camera visibility from the interactable cube.
Can't create delegates (or dynamic code) in the constructor. It must be in BeginPlay.
When overriding BeginPlay, you need to have Super::BeginPlay or else you can't move the mouse or directional keys.
This is a valuable comment. Thank you!
did you try restart editor for constructor changes take affect?
I think I have in previous tests and that doesn't always work from the results I remember getting so I've tried providing a fail-safe approach.
no problems) thank for the video! but hot reload buggy working with constructors and with some changes in header files, try it for confirm when you have a free time. I'm always restarting editor with these changes otherwise to find why and what - will be very difficult.
It's not necessary to disable camera collisions. Instead, in the collision channels of the mesh, set the camera channel to ignore. Though I'm curious to why you chose a static mesh over using a box collision component? My understanding is the collision components are cheaper to run.
A collision update is going to be about the same and the only reason it would be cheaper is that it's not rendering but we have the cube as a visual representation any so rather than stacking up the components I've just used the collision on the cube that's readily available.
@@DevEnabled Good to know. Thanks.
mesh collision has a slightly different signature than box or sphere collision. That's the part that was throwing me off.
Mine worked without overriding begin play
Sir at 9:09 I have done like you but I am getting this error :- error C2039: 'Execute_OnInteraction': is not a member of 'IInteraction_Interface'.......can you tell me why?Thankyou.
The issue in constructors is that you shouldn't add anything dynamic in them. Everything dynamic should go into BeginPlay. I've had this bite me in the ass before - for example - creating Dynamic material instances in constructors won't work etc.
Yeah, they can be a bit of strange one. It can definitely cause issues storing dynamic variables in them but things like the mesh which you'd already need to have defined in the header should be readily accessible there to reference.
Thank you thank you thank you! I couldn't figure out why my events weren't firing. I was following the example posted above where they were put in the constructor and it wasn't working. Moved it to begin play and worked!
But what if i have about 100 enemys of the same type in the game. Do i have to add my function to every instance of the enemys?
Make a class that all the enemies inherit from
It seems that it's true that UE's C++ API is a Mess and that the docs can't help you much...Even if you are a C++ dev like me... I'm probably gonna give up and return to Unity, I don't like blueprints at all because I want to write actual code.
Unity can be good too.
exactly. I prefer c++ to c# but unreal will make you hate c++ because of their useless documentation. As for blue-print, I would rather write assembly code than use blueprints. lol.
Unreal C++ documentation is indeed very poor with no code samples. You have to fish samples from the videos like this. But I'll not go to Unity, I'll continue to suffer with Unreal code.)
looks like they really shafted their documentation recently. They show nothing of this caliber now :(
Did they changed the Documentation? Its extremly bad now with absolutly no example and just a very short explenation.
I think they have been going through updating the documentation. I know they've made the includes much easier to find which is nice. Not sure if they're also simplifying some of the examples for some reason though.
Oh, and great Video!
@@DevEnabled ok, thank you. I dont really understand delegates or what AddDynamic really does. Do you maybe have a short explanation for me ? (:
they did really removed all the coding on the docs but only give explanation
this is really bad , i cant find the code u are referring in the video , so i m stuck
they update it and make it worst , all coding sample is gone now :(