So, why exactly doesn't this work? (Set World Position, huh?)

Hi. :wave:

So I made this simple function that calculates screen corner positions and translates it to world space.

And it clearly is working when I test it with Draw Debug Sphere:

But as soon as I try to set the world position of something else, they just disappear and I do not understand why…


Can someone smarter please explain this to me, because I am lost.
(Also, the tick is just for experimenting, I don’t use it in the actual game)

Thank you for any replies and ideas!

Hey @Shounenn!

So you’re taking a 2D Vector and returning a 3D vector- that’s where the math is getting confusing.

Because in a vector 2D, X=width and Y=height, but in UE: X=Depth, Y=width, and Z=Height. (According to world center)

Depending on your rotation and your facing of where world center is these numbers can change quite a bit, subtracting, say, 20 from the Y (which is left and right axis of world center) depending on your rotation can really change where this ends. What does it do if you don’t alter it in any way?

Let us know! :slight_smile:

1 Like

Hey, thanks for the reply.

In the first image (in-game) is the unaltered code where the debug sphere is in the literal corner of the screen. The second one is the same thing, but with that -20 subtracted from the Y.
And if I try to set the position without the -20 for the actor reference, it still does the same thing.

And with the debug sphere it works perfectly. I don’t really get what you told me haha. Are you saying that that actor’s own rotation is affecting where it ends up in the converted X and Y of the screen space, in world space?

Isn’t world space just literally taking the thing which usually has it’s pivot point in the centre (or close to it anyways) and then taking that pivot point and moving it to the world space location provided (which again, is the right location shown by the debug sphere)?

Do I need to change something about this approach? Add something, or? I sort of understand what you said, but still am very confused.

I will try to debug it by placing another camera that views the whole thing from a far and see where the Bee ends up. My game’s camera is in a fixed location

I apologize, I misunderstood what you were saying was happening in the first post.

Some things to do to debug, after Shift+F1 and then Ejecting:
Find it after the spawn in the world outliner, and double click it to go to it. If you can’t find it in the outliner it might not be there in the first place, and if it is, where it ends up would be a clue!

Also generally you don’t want to use a “Set world Location” on a Root component. Just use “Set Actor Location”, it’s a lot safer from weird things and happenings. :slight_smile:

1 Like

Yeah I was debugging the issue by ejecting and then looking for it and it seemed that it worked nicely, but the actor itself was too close to the camera to actually be in the view+Camera clipping

So basically, this system works as expected, it’s just that I had to adjust the values and subtract the Y much more for it to actually appear in the view, since it had a slight Z offset as well in itself so it basically was above view haha.

In my 5 years of using Unreal Engine, for some reason I had no idea that you could eject from a pawn while testing in actual window and not just “simulate”…wow :sweat_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.