Hello, so I’ve noticed a couple of little issues in my file but this is the first time that it’s seemed to crash every time I attempt to play.
Let’s look at my code first. This is in version 4.19
// Called every frame
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// LINE TRACE and see if we hit any actors with physics body
// Get Player viewpoint this tick
FVector PlayerViewPointLocation;
FRotator PlayerViewPointRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
OUT PlayerViewPointLocation,
OUT PlayerViewPointRotation
);
FVector LineTraceEnd = PlayerViewPointLocation + PlayerViewPointRotation.Vector() * Reach;
// if the physics handle is attached
if (PhysicsHandle->GetGrabbedComponent())
// move the object we're holding
{
PhysicsHandle->SetTargetLocation(LineTraceEnd);
}
}
void UGrabber::Grab()
{
UE_LOG(LogTemp, Warning, TEXT(“Grab Pressed”))
//TODO ray-cast and grab
auto HitResult = GetFirstPhysicsBodyInReach();
auto ComponentToGrab = HitResult.GetComponent();
auto ActorHit = HitResult.GetActor();
// try to reach any actors with physics body collision channel set
///if we hit something then attach a physics handle
if (ActorHit)
{
// attach a physics handle
PhysicsHandle->GrabComponentAtLocationWithRotation(
ComponentToGrab,
NAME_None,
ComponentToGrab->GetOwner()->GetActorLocation(),
ComponentToGrab->GetOwner()->GetActorRotation()
);
}
}
So I poked around a bit and did a little debugging. A couple things I’ve found:
-
commenting out the PhysicsHandle stuff in the tick component allows the game to run without error, but the chair won’t move, obviously.
-
I tried printing out what component it was attempting to grab and occasionally it would return (null). That didn’t bother me. But occasionally it would return Korean characters. Something like “꽸홭翽”
I tried deleting and then replacing the chair and found that now wherever I was in the room, it would return the Korean chracters, not just when I was at the chair.
Thanks for taking a look. Let me know if you have the same problem or if you know of a fix.