I am getting the following error with this code. I am getting confused on what to do and have searched google for a lot of answers but I don’t know what they are saying to do. I tried the declaring the pointer in the the TeleportPortal.h file and assigning it there but that did not work.
The error is happening on PlayerCharacter()->GetCharacterMovement()->GetCurrentVelocity()
void ATeleportPortal::TeleportActor(AActor* ActorToTeleport) {
if (ActorToTeleport == nullptr || Target == nullptr) return;
//Get and save Player Velocity (from their MovementComponent)
FVector SavedVelocity = FVector::ZeroVector;
AFPPersonalProjectCharacter* PlayerCharacter = nullptr;
if (ActorToTeleport->IsA(AFPPersonalProjectCharacter::StaticClass())) {
PlayerCharacter = Cast<AFPPersonalProjectCharacter>(ActorToTeleport); //sets the playercharacter to actor we are teleporting
SavedVelocity = PlayerCharacter->GetCharacterMovement()->GetCurrentVelocity();
}
}
Here are my #include statements on both TeleportPortal.cpp and TeleportPortal.h
Adjusted the code a bit but the error is still there:
void ATeleportPortal::TeleportActor(AActor* ActorToTeleport) {
if (ActorToTeleport == nullptr || Target == nullptr) return;
//Get and save Player Velocity (from their MovementComponent)
FVector SavedVelocity = FVector::ZeroVector;
AFPPersonalProjectCharacter* PlayerCharacter = nullptr;
if (ActorToTeleport->IsA(AFPPersonalProjectCharacter::StaticClass())) {
PlayerCharacter = Cast<AFPPersonalProjectCharacter>(ActorToTeleport); //sets the playercharacter to actor we are teleporting
SavedVelocity = PlayerCharacter->GetCharacterMovement()->GetCurrentVelocity();
}
//Compute and apply new location
FHitResult HitResult;
//FVector NewLocation = UTool::ConvertLocationToActorSpace(ActorToTeleport, this, Target);
}
Angle brackets does an implementation-dependent search (essentially looking for system headers) which wouldn’t exist.
Use quotes to ensure that it just tries to find a file at that relative path. So change it to: