Dear Kris,
Based on tests I did just now I dont think Skeletal meshes are currently “wired” to track overlap events.
If any devs or people who know better see this, here are my tests below that lead me to this conclusion.
Note I am setting
CurrentWeaponSkelMesh->bGenerateOverlapEvents = true;
CurrentWeaponSkelMesh->bMultiBodyOverlap = false;
every single tick,
but
ShouldTrackOverlaps()
is always returning false for my skel mesh, much as the comment below in the Source code says:
Primitive Component.h
/** Returns true, if this component tracks overlaps. This might be false for multi-body components like SkelMeshes or Destructibles. Even if
false, other components can still overlap this component. */
virtual bool ShouldTrackOverlaps() const { return true; };
my test code
//~~~~~~~~~~~~
//TEST ONLY
VICTORY_GETPC
//test player sword only
if(!IsPlayer) return;
//~~~~~~~~~~~~
VictoryPC->Optimize(GetName());
if(!CurrentWeaponSkelMesh) return;
VictoryPC->Optimize(CurrentWeaponSkelMesh->GetName());
//does track overlaps?
CurrentWeaponSkelMesh->bGenerateOverlapEvents = true;
CurrentWeaponSkelMesh->bMultiBodyOverlap = false;
if(CurrentWeaponSkelMesh->ShouldTrackOverlaps()) VictoryPC->Optimize("YES tracks overlaps");
else VictoryPC->Optimize("NO DOES NOT TRACK overlaps");
TArray OverlapActors;
CurrentWeaponSkelMesh->GetOverlappingActors(OverlapActors);//, AVictoryPlayerCharacterBase::StaticClass());
int32 Numlaps = OverlapActors.Num();
VictoryPC->OptInt("Num Overlaps", Numlaps );
if(Numlaps > 0 && OverlapActors[0]) if(JoyHUD) JoyHUD->Optimize(OverlapActors[0]->GetName());
//~~~~~
results:
#So What is the Solution?
#Trace Component
You will probably want to component-level traces each tick whenever you are anticipating skeletal component to hit something important.
I have a BP node to facilitate the use of the existing trace BP nodes, called TraceData
which helps you calculate the trace start and trace end
http://forums.epicgames.com/threads/977316-(21)-Rama-s-Blueprint-Node-Library-As-a-Plugin-For-You!-No-Code-Compile-Required?p=31719668&viewfull=1#post31719668
then I think the node you want is Trace For Objects
and then you can specify what types objects you care about your skel mesh component hitting
#Why No Overlap Events for Skel Meshes by default?
Cause constantly generating overlap events for multi-body skel meshes is most likely very costly to track for every single skel mesh all the time, again if anyone knows more about this let us know please
#Actor Hit Event
you could use the Actor-level hit event and check which component was registered as having received/done the hit
UFUNCTION(BlueprintImplementableEvent, meta=(FriendlyName = "Hit"))
virtual void ReceiveHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit);
#Accuracy
The actor-level hit is less accurate because it is done with the actor capsule, I think,
but depending on your game/MOVIE goals this might be plenty of accuracy!