I want to make door opening and closing like amnesia. So, I used SweepSingleChannel() to find the door by tagging the door with “Door” collision, then when I’m moving the mouse and stopping the mouse, it keeps returning on the same rotation as before. My Code:
void UHandler::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if(bIsGrabbing)
{
UPhysicsHandleComponent *PhysicsHandle = GetPhysicsHandle();
if (PhysicsHandle->GetGrabbedComponent() != nullptr)
{
PhysicsHandle->GetGrabbedComponent()->WakeAllRigidBodies();
FRotator TargetRotation = FRotator(0, ForceRotation , 0);
PhysicsHandle->GetGrabbedComponent()->AddLocalRotation(TargetRotation);
}
}
}
ForceRotation is set like this:
void APlayerCharacter::TurnRightLeft(float AxisValue)
{
AddControllerYawInput(AxisValue * RotationRate * GetWorld()->GetDeltaSeconds());
if(bHasGrab)
{
if (doorHandler != nullptr)
doorHandler->SetForceRotation(AxisValue);
}
}