I am trying to teleport a pawn when it contacts a portal using Set Actor Location. The collision triggers and it looks like the correct parameters are being passed and the function returns ‘true’, but the pawn stays in place.
I have looked around the forums and online for solutions, but none of them seem to work. I have tried using Set World Location instead, the pawn’s components are set to ‘Moveable’, I have tried enabling and disabling the ‘Teleport’ flag, and I have tried calling the pawn globally. No errors are being triggered as far as I can see.
This feels like it should not be complicated and I am probably missing something glaringly obvious, but I have been trying for hours and nothing seems to work. Thanks for the help in advance.
Thanks for the reply. I just tried Set Actor Transform as you suggested, but it unfortunately didn’t work either. I have tried with Teleport off, but nothing happens as well. I moved the teleport checkpoint to somewhere I could see it on screen if anything did happen, but nothing appears at all, not even for a frame. I also opened the Output Log, but no errors appear and print string functions return the proper values.
Unfortunately, your solution didn’t seem to help my case. Fortunately, I think I did fix my issue, though I am confused as to why it works. I was able to get the pawn to move by using Set World Location and moving the pawn’s Static Mesh Component instead of the DefaultSceneRoot. I thought that moving the root should also move any subcomponents along with it. If this isn’t intended behavior, is there a setting I may have overlooked to rectify this?
What might be happening is that when you teleport the actor as a whole, the ball’s transform isn’t inheriting the actor’s new location. And I suspect this might be the case entirely if that ball is moving around using rotation?
Try print strings showing the actor’s location and the ballmesh, I suspect once that ball starts moving those values drift apart.
And no, it’s not recommended to be teleporting an actor’s components apart typically.
Yes, that’s exactly what’s happening. I didn’t realize enabling physics on the mesh would cause its transform to change relative to the actor’s. Is there a way to link the actor’s transform to match the mesh or replicate this behavior through the actor itself? I am using the Add Torque function to roll the ball around, and it only seems to accept the Mesh rather than the Actor as input. I can’t find a setting to enable physics on the pawn or root.
If there’s not an easy solution, I’m content with the workaround I found, even though it’s probably not ideal.
Yeah, so what everyone is saying is that there’s likely something still moving your meshes. You must stop those first, move the actor and then re-enable whatever was moving the meshes (movement, physics, custom blueprints/code, input actions, etc.) In my first failed game, I had to do this to pick up a log.
meshComp->SetSimulatePhysics(false);
Note that physics runs in parallel with your code. It continues to update your object positions and rotation even as your own code or blueprint runs. Turning it off tends to be rather immediate but there’s no guarantee. I’m not sure how to check when it’s safe to move an object. Not only that, but if anything that is moving your meshes has state, that state must be reset.
As to the question about moving the mesh’s transform relative to the actor, here’s a bit of info that may not be obvious. The Actor doesn’t actually have a transform. When you modify the Actor’s transform, it uses the root component’s transform. So if you have a mesh that you want it to represent your actor’s position, just make the mesh the root component. So when the mesh position is moved, your actor MUST move with it because the mesh transform IS the actor’s transform.
Replacing the root component with the Mesh component was the solution, I’m learning Unreal and didn’t know that was possible. The actor-based functions now work perfectly.