143258
(143258)
1
Hi Everyone
I want to make A Component with overlaps events but I have some problems which I can’t solve by myself, So it would be cool if anyone could help me.
This is the box which should trigger the overlap events. I wrote this in the .h
This is what I was able to do so fare and it is in the .cpp
I hope I gave you all information you need if not, please ask.
Thanks for everyone’s help!
1 Like
I guess you are not confident with C++ right ?
Hi 143258,
This is the general layout for overlap events in C++ classes.
[.h]
UPROPERTY(EditAnywhere, Category="Collision")
USphereComponent *SphereComp;
UFUNCTION( )
void BeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult);
[.cpp]
MyCharacterClass::MyCharacterClass()
{
SphereComp = CreateDefaultSubobject<USphereComponent>( TEXT("SphereCollider" ) );
}
void MyCharacterClass::BeginPlay( )
{
if( SphereComp )
{
SphereComp->OnComponentBeginOverlap.AddDynamic( this, &MyCharacterClass::BeginOverlap );
}
Super::BeginPlay( );
}
void MyCharacterClass::BeginOverlap( UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult )
{
// overlap code here
}
1 Like
143258
(143258)
4
Not realy.
Do you know what I did wrong?
I suggest your first use Blueprints cause obviously you are a very beginner in C++. Blueprints are great and visual so it’s a good place to start.
143258
(143258)
6
You are right. After a half year I noticed that there are things that I couldn’t do so I’a trying to write c++ now
143258
(143258)
7
Thanks that you helped me. It is realy cool that you took the time to help me.
: )