Hi everyone!
I am having a bit of trouble understanding Overlap events when it comes to items equipped to a socket. When it is unequipped/on the ground, it has no problem firing. However, when I attach it to my Player Character, I can get the event to fire only on the opposing actor, and not my weapon.
First of all, the code on my ItemClass.cpp:
AItemClass::AItemClass()
{
// Create the item capsule and attach it to the Root Component
ItemCapsule = CreateDefaultSubobject<UCapsuleComponent>(TEXT("ItemCapsule"));
= ItemCapsule;
// Set up the On Hit event.
ItemCapsule->OnComponentHit.AddDynamic(this, &AItemClass::OnHit);
ItemCapsule->OnComponentBeginOverlap.AddDynamic(this, &AItemClass::OnOverlap);
// Lastly, create the Mesh component and attach it to the capsule.
InteractableMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ItemMesh"));
InteractableMesh->SetupAttachment();
// Simulate physics and notify rigid body collision.
InteractableMesh->SetSimulatePhysics(false);
//InteractableMesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
InteractableMesh->SetNotifyRigidBodyCollision(true);
ItemCapsule->SetSimulatePhysics(false);
ItemCapsule->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
// Can this item deal damage?
CanDamage = false;
}
As for my “equip” settings, they are very simple:
void AItemClass::setMeshToActor(USceneComponent* Component, FName SocketName)
{
ItemCapsule->SetSimulatePhysics(false);
ItemCapsule->AttachToComponent(Component, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), SocketName);
}
As for my settings:
-
Event overlap events are enabled.
-
I’ve tried enabling and disabling physics, and from what I can tell, this only affects hit events, and not collision events
-
I have set the collision properties to overlap. I even had my weapon blanket overlap everything. I’ve created a new overlap event called Weapon, and have set everything to overlap with it, and I still haven’t managed to get it to do anything at all.
The only thing that I can think of is equipping to a socket changes settings somehow, but I can’t figure out what that is. Any help would be appreciated. Thank you!