Hey all, I thought I’d share. So if anyone is wondering how to get rotation going and is currently on Episode 83 - Refactoring. Not sure if Ben is adding this later, just in case he isnt, here is the changes I made to add rotation to the object as well as making it rotate “back up” into correct position and will YAW with the rotation of the playerpawn.
In Grabber.h under private:
#pragma region MyHelpers
/// setup struct to store player location and rotation
struct playerviewpointlocationandrotation {
FVector location;
FRotator rotation;
} PlayerViewPoint;
/// sets the rotation and location in struct above
void GetPlayerViewPointLocationAndRotation();
#pragma endregion
then in Grapper.cpp
void UGrabber::GetPlayerViewPointLocationAndRotation()
{
/// stores playerviewpoint location and rotation in struct for reuseability
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(PlayerViewPoint.location, PlayerViewPoint.rotation);
}
and finally as an example inside your TickComponent
if (PhysicsHandle->GrabbedComponent)
{
/// rotate and move the object we're holding
GetPlayerViewPointLocationAndRotation();
PhysicsHandle->SetTargetLocationAndRotation(GetReachLineEnd(), FRotator(0.0f, PlayerViewPoint.rotation.Yaw, PlayerViewPoint.rotation.Roll));
}
with this being refactored you can now obviously also go ahead and make those GetRechLineStart/End dissappear or simply refactor if you’re into getters that much
Hope this helps someone.