GetWorldLocation and GetActorLocation Return Invalid Results -- Teleport Fails

I’m currently attempting to teleport my currently controlled pawn from one location to another. The target location is marked by an empty actor ball, which (in theory) should provide me with the location I want to teleport to during runtime:

However, I get a completely incorrect location when using either GetActorLocation or GetWorldLocation. Both functions produce the same result as shown here:

image

Using this incorrect location, it spawns me in yet another unforeseen location here:

So not only is it spawning me in the incorrect location, it’s doing so at a seemingly random location. This is consistent every time I run this code.

I’ve verified that I’m getting the correct actor when I look for it (the empty ball), however, the output locations of both functions are incorrect.

Any thoughts as to why this is happening?

Can you share this part of the BP?

So here I have two actors – one with tag Spawn_1, where I’d like my pawn to teleport to, and Lookat which is where the pawn should be looking after teleporting.

Both of these calls to Get All Actors with Tag return a single element, so I know what actor it’s returning.

Update: It looks like the problem is with this yellow box around my simulation environment:

Excuse my ignorance, but does this signify the bounds of my map, even though it, in reality, extends much farther than that yellow box? How do I expand this yellow box?

Scale it? I don’t know what is the yellow box.

Imo the problem could be:

  1. you are assuming the component of the actor you are trying to teleport to has the same world location as its rootComponent.
  2. Actor is not moving how you are predicting and it is actually sending you to correct location.
  3. You are teleporting to the wrong actor.

When I manually put in the locations of both the spawn and look at actors for my teleport function, it put me somewhere completely on the other side of the map… is it possible that the origin is being reset to some location when I launch my game?

(0, 0, 0) seems to be the “Player Start”, so I think that’s where its setting the origin. Interesting.

See point # 1. :rofl:

Ah RIP :joy:

Excuse my ignorance, I suppose I don’t quite understand how root components work, then. Would I need to, then, get the root component of the actors I want to teleport / teleport to instead of how I was doing it prior?

Update: So I navigated to the point where I wanted to teleport to in the game, and I printed to the screen the current location. When I manually put that location in my blueprint, it “snaps” me to light post, similar to how it was “snapping” me to the trees. Why is my pawn melding itself to the side of objects after the teleport?

It depends how that actor moves / behaves. Typically you want blueprint to be self contained, meaning the root has everything inside attached, but enabling physics, for example, bfeaks that connection. So you might think the actor (root component) location is X, but the component (could be the camera or any visible mesh) is X + Y.

What you did above is not wrong, you just have to confirm the components are where you think they are so they move coherently.

Idk. What I do know is that pawns do not have free will… it’s only doing what you are telling it to do. :grimacing: