Hey. I’m trying to use the custom collision channel ECC_GameTraceChannel1 for overlapping.
Here is my volume class:
#include "MyGame.h"
#include "TeamPushingVolume.h"
ATeamPushingVolume::ATeamPushingVolume(const class FObjectInitializer& OI)
: Super(OI)
{
this->bPhysicsOnContact = true;
GetBrushComponent()->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
GetBrushComponent()->SetCollisionObjectType(ECollisionChannel::ECC_GameTraceChannel1);
GetBrushComponent()->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
// Uncommenting this line, then it enters ActorEntering/LeavingVolume
//GetBrushComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap);
GetBrushComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_GameTraceChannel1, ECollisionResponse::ECR_Overlap);
}
/* This doesn't work either
void ATeamPushingVolume::BeginPlay()
{
Super::BeginPlay();
GetBrushComponent()->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
GetBrushComponent()->SetCollisionObjectType(ECollisionChannel::ECC_GameTraceChannel1);
GetBrushComponent()->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
//GetBrushComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap);
GetBrushComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_GameTraceChannel1, ECollisionResponse::ECR_Overlap);
}
*/
void ATeamPushingVolume::ActorEnteredVolume(AActor* Other)
{
if (auto Pawn = Cast<AMyPawn>(Other))
{
LOG_BLUE(TEXT("player entered"));
}
}
void ATeamPushingVolume::ActorLeavingVolume(AActor* Other)
{
if (auto Pawn = Cast<AMyPawn>(Other))
{
LOG_BLUE(TEXT("player left"));
}
}
Header file
#pragma once
#include "GameFramework/PhysicsVolume.h"
#include "TeamPushingVolume.generated.h"
UCLASS()
class SUPRABALL_API ATeamPushingVolume : public APhysicsVolume
{
GENERATED_BODY()
public:
ATeamPushingVolume(const class FObjectInitializer& OI);
public:
virtual void ActorEnteredVolume(AActor* Other) override;
virtual void ActorLeavingVolume(AActor* Other) override;
//virtual void BeginPlay() override;
};
And the entries in the very bottom of pawn constructor
GetCapsuleComponent()->SetCollisionObjectType(ECollisionChannel::ECC_Pawn);
GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_GameTraceChannel1, ECollisionResponse::ECR_Query);
I also tried setting the CapsuleComponent collision response in BeginPlay of the Pawn… To no avail.
My Default.ini has the following entry
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1, Name=TeamAlpha)
Now… What the devil am I missing here? I can’t find a lot of topics about it except that people had trouble getting it to work as well.
Every time I changed something and recompiled I deleted the TeamPushingVolume and added a new one (to get it to initialize from anew).
Is it bugged or is something wrong with my code?
Edit: I also read a post where the person stated the with blueprints it works, but with code it doesn’t…? Sounds a bit buggy.
Edit2:
Also tried adding this line to editor
+EditProfiles=(Name=“Pawn”,CustomResponses=((Channel=TeamAlpha, Response=ECR_Block))
Doesn’t work.