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. The player is then able to carry the object around, continuing its relative location.
However, I am trying to do something along the lines of this video (https://youtu.be/w6Y7Z1R_z9w) which employs forced pespective. 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. Of course I am not tracing lines around the object’s vertices just quite, but I am just testing stuff right now before do that process.
And that is when I tried to use the TeleportToFunction; however, instead of the picked-up object being teleported, it is 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!