C++ Overlap events don't work
Hi, I have some problems with c++. I tried to copy overlap events tutourials from various sources, but none of them worked. I copied this video 1:1: https://www.youtube.com/watch?v=NAbLfvTJLrw. The problem is this line of code:
And I have another question I dont understand: I always have to include " #include "Components/SphereComponent.h"" to my cpp file to use sphere/box/capsule collisions. In the tutourials, the never have to implement this. Why?
asked Jul 31 '18 at 04:10 PM in C++ Programming
The likely cause is that the delegate signature is incorrect. The tutorial you referenced looks to be outdated a bit and the new signature you're looking for, found in PrimitiveComponent.h still, includes an extra "OverlappedComponent" pointer like so:
So your function body should read
If that doesn't fix the issue then it could be a problem with where you're binding to the function (I've had some weird problems with binding it in the constructor in the past), so you could try binding it on begin play instead. If not that then it could be that the collision settings are such that overlap events aren't triggered, but if you're just using the default settings from a new project then that shouldn't be an issue. Or even having bGenerateOverlapEvents to true is necessary. But try it in that order first and see if it works.
I hope that helps!
To answer your second question though, as of 4.16 the engine now uses an "Include What You Use" system for compiling dependencies so compile times can be faster, which means you have to include what you need explicitly since many header files that used to be included by default are no longer included. The documentation explains it a lot better than I can. Link
answered Jul 31 '18 at 04:56 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here