I have the following code:
if (GetWorld()->LineTraceSingleByChannel(*HitResult, StartTrace, EndTrace, ECC_Visibility, *TraceParams))
DrawDebugLine(GetWorld(), StartTrace, EndTrace, FColor(255, 0, 0), true);
TeleportTo(FVector(HitResult->Actor->GetActorLocation()), GetWorld()->GetFirstPlayerController()->GetControlRotation(), false, true);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT(“You hit: %s”), *HitResult->Actor->GetName()));
Although not everything, I have pickup class which allows objects with the class to be picked up by the character. During the pick up, the object in default would be situated right smack on the middle of the crosshair.
Therefore in the code above, right when the character picks up an object (bHoldingItem = true), it will trace rays, and it will return whichever actor is in current contact with the trace line. At this moment, I want the picked-up object to be teleported right to the location of where the trace line hits the actor.
And that is when I tried to use the TeleportToFunction; however, instead of the picked-up object being teleported, it is instead teleporting the player. Anyway to fix this? I am new to Unreal C++, so excuse me if this may seem rudimentally.
Got a school project to do folks!