add grab sucess/fail checks with error messages
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include "SenseGlove/Components/SGTouchComponent.h"
|
||||
#include "SenseGlove/Components/SGVirtualHandComponent.h"
|
||||
#include "SenseGlove/Components/SGWristTrackerComponent.h"
|
||||
#include "SGLog/SGLog.h"
|
||||
|
||||
struct ASGPawn::FImpl
|
||||
{
|
||||
@@ -1233,14 +1234,20 @@ void ASGPawn::GrabLeft(AActor* Actor)
|
||||
GrabComponent->GetAttachmentScaleRule(),
|
||||
GrabComponent->GetAttachmentWeldSimulatedBodies())
|
||||
};
|
||||
FName SocketName{GrabComponent->GetAttachmentSocketName()};
|
||||
|
||||
const FName SocketName{GrabComponent->GetAttachmentSocketName()};
|
||||
ensureAlwaysMsgf(SocketName != NAME_None, TEXT("invalid attachment socket name!"));
|
||||
|
||||
Actor->AttachToComponent(HandLeft, MoveTemp(AttachmentRules), MoveTemp(SocketName));
|
||||
|
||||
const bool bAttached = Actor->AttachToComponent(HandLeft, MoveTemp(AttachmentRules), SocketName);
|
||||
if (bAttached)
|
||||
{
|
||||
ActorLeftHandGrabbing = Actor;
|
||||
}
|
||||
else
|
||||
{
|
||||
SGLOG_ERROR("Failed to grab the actor with the left hand!", Actor, SocketName);
|
||||
}
|
||||
}
|
||||
|
||||
void ASGPawn::GrabRight(AActor* Actor)
|
||||
{
|
||||
@@ -1261,14 +1268,20 @@ void ASGPawn::GrabRight(AActor* Actor)
|
||||
GrabComponent->GetAttachmentScaleRule(),
|
||||
GrabComponent->GetAttachmentWeldSimulatedBodies())
|
||||
};
|
||||
FName SocketName{GrabComponent->GetAttachmentSocketName()};
|
||||
|
||||
const FName SocketName{GrabComponent->GetAttachmentSocketName()};
|
||||
ensureAlwaysMsgf(SocketName != NAME_None, TEXT("invalid attachment socket name!"));
|
||||
|
||||
Actor->AttachToComponent(HandRight, MoveTemp(AttachmentRules), MoveTemp(SocketName));
|
||||
|
||||
const bool bAttached = Actor->AttachToComponent(HandRight, MoveTemp(AttachmentRules), SocketName);
|
||||
if (bAttached)
|
||||
{
|
||||
ActorRightHandGrabbing = Actor;
|
||||
}
|
||||
else
|
||||
{
|
||||
SGLOG_ERROR("Failed to grab the actor with the right hand!", Actor, SocketName);
|
||||
}
|
||||
}
|
||||
|
||||
void ASGPawn::ReleaseLeft()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user