How to teleport Vehicle Player Pawn?

I tried using the Get Player Pawn > Teleport (binded to a key event).
The Vehicle didn’t want to teleport to the designated location. It pretty much do nothing.
Is there anything special needed for telporting Vehicle Pawn?
I believe this action works in 4.1 on standard FPS pawn.

Thanks in advance.

Can you show a screenshot of how you have your blueprint hooked up?

I’ve placed this in the Vehicle Pawn that I use as a default pawn in game info.
I’ve also tried this same exact function in Level Blueprint and it didn’t do anything.
I’ve verified the input ResetCar was executing using Print String.

I tried this and notice it worked fine unless you are doing multiplayer screens or running the play option with dedicated server in which case I think it needs some replication.

If you are wanting to make this work in multiplayer just create a CustomEvent and under replication make it Run On Server and check Reliable(which gives it a high priority).
Drag off the Keybind and then type in the name of your custom event which should create a blue version of it.

Then add your custom event and connect it to teleport. I would change the Get Player Index to Get Reference to Self so that you don’t teleport other players around.

I will try this later today when I get home.
I don’t remember setting a multiplayer game though.
I’m using the vehicle template from 4.2 is there anything special about that template that automatically set it as a multiplayer? (will investigate things myself too later).

Thanks again for the reply, I’ll let you know the result.

It didn’t work :frowning:
I made a new clean UE4.2 Vehicle template and tried the above teleport method, it still didn’t work.
I might migrate my Vehicle to my FPS project and see whether the teleport function work or not later on.
Any other ideas?
Thanks for the reply btw.

Ok I gave up on teleporting my car using teleport / set location function. It’s completely non working for vehicle pawn.
So I decided to just destroy the actor and reposses it.
This doesn’t solve the fundamental problems, but at least gets me to where I want for now.
I really hope somebody knows the answer on why I can’t use standard teleport for vehicle pawn.
I’ve double checked the teleport and confirmed it that on the same project with a regular character pawn teleport worked.

I suspect the vehicle blueprint in the demo has been built for multiplayer. I’m no expert but if UE4 is at all like Unity in a multiplayer environment, i.e. where dedicated server is ticked or you have multiple clients in the simulation then movement on the player pawns is restricted to being simulated on the server (to prevent clients cheating). I could be wrong though.

I’ve tested my Vehicle Pawn on an empty FPS template project and it still won’t teleport. But FPS Character teleport just fine.
So it’s definitely something with the vehicle pawn that doesn’t allow it to teleport.

Anybody have the real solution for teleporting Vehicle pawn? Please…
The destroy actor temporary solution break some attributes that I’ve set on the previous pawn and I don’t want to keep hacking things because of not knowing how to teleport my vehicle pawn properly :frowning:

Hi there,

I ran into the same issue and the basics of the issue is that the physics body on the skeletal mesh needs to be teleported along with the actor itself.

I am not sure if you are just using blueprints or also are adding c++. We use c++ and wrote a teleport function to our vehicle which does the following:

Calls StopMovementImmediately on the movement component
Then calls Mesh->SetAllPhysicsPosition(GetActorLocation());
Finally calls Mesh->SetAllPhysicsRotation(GetActorRotation());

If you are using blueprints only I dont see anywhere this stuff is accessible. If you do have any C++ I recommend you either add a new blueprint function which does the same on your vehicle c++ class OR add a static function to your blueprint library c++ class.

Alternatively you could continue to use the teleport blueprint function on your actor, and in your c++ dervied vehicle class override virtual void TeleportSucceeded(bool bIsATest) (from AActor) and call the three functions listed above.

The real function which does the actual teleport is void FBodyInstance::SetBodyTransform(const FTransform& NewTransform, bool bTeleport). As long as your provide true to the second param, the body is then teleported without physics.

Hope this helps

1 Like

Unfortunately I don’t have good knowledge on doing things in C++ :frowning:
Somehow I still can’t believe I can’t achieve the same thing in BP.
I’m trying to understand your function here.
(Since obviously mine didn’t work lOl)

Calls StopMovementImmediately on the movement component
In BP: I did found the function of Vehicle Movement > StopMovementImmediately.

Then calls Mesh->SetAllPhysicsPosition(GetActorLocation());
In BP: I found the function for the Mesh to Set new Location.

Finally calls Mesh->SetAllPhysicsRotation(GetActorRotation());
In BP: I found the function for the Mesh to Set new Rotation.

But I don’t exactly understand in what causes the vehicle to teleport in your next description.

Greatly appreciate the help.
Shamelessly requesting more info XD

No worries at all :slight_smile:

Yeah Stop movement immediately is available via blueprints. The other two however are not, which is where your issue will be.

I assume the skeletal mesh you have has a physics body setup. This is how our is. Setting the position of the mesh doesnt actually move that physics body, which is what is doing all the real work.

What you need to do is tell the physics body that it too has to move. And from what I can see, there is no way to do this in blueprints without writing some c++ code.

Do you have your project setup for c++ at all? If you do, the easiest thing to do to see if this fixes your case, is to create your own Blueprint function library class and add a function which will teleport the physics of a skeletal mesh component. This should also move the actor. It does the way we have it setup.
.

Had to split this, since it was too long… Here is the code:

Make a header file called MyNewBPFunctionLibrary.h:

#pragma once

#include "MyNewBPFunctionLibrary.generated.h"

UCLASS()
class UMyNewBPFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_UCLASS_BODY()

public:

	UFUNCTION(BlueprintCallable, Category = "MyNewFunctions")
	static void TeleportPhysicsBody(USkeletalMeshComponent* Mesh, const FVector& NewLocation, const FRotator& NewRotation);

}

And in your cpp file (MyNewBPFunctionLibrary.cpp). Note whatever you call your game, thats what YourGameModule should be.

#include "YourGameModule.h"
#include "MyNewFunctionLibrary.h"

UMyNewFunctionLibrary::UMyNewFunctionLibrary(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{

}

void UMyNewFunctionLibrary::TeleportPhysicsBody(USkeletalMeshComponent* Mesh, const FVector& NewLocation, const FRotator& NewRotation)
{
	Mesh->SetAllPhysicsPosition(NewLocation);
	Mesh->SetAllPhysicsRotation(NewRotation);
}

My project is blueprint base and yes I use PhAT in the mesh component.
I have no idea how to do stuff in Unreal4 w/ C++ :frowning:

I’ll try to do some learning on how to use the code you paste above.
Thanks again for explaining it and giving me the C++ blueprint node.

No worries at all, if you give it a go and run into issue let me know and ill try and sort you out. Good luck!

I have been having a very similar issue with something I have been working. I have found somewhat of a workaround, however this only works server-side so far, and not for clients. I’ll put it simply.

Disable physics > Delay > Teleport > Delay > Enable physics

I have found that this does work for my vehicle pawn, however it only works for the server. Clients seem to jump to the destination, then back to where they were. I’m still working on it, but it should be enough to get the ball rolling.

Sorry, only have paint to work in at the moment to get a picture for you.

Also, using 4.4.3 - Don’t think this should have any affect though.