I am a new to unreal engine and here as well, as this is my second forum post, and am need of some help with two blueprint problems. For your information, i am making a 2D game. As for the first issue, I’m trying to get a paper flipbook actor - From the paperZD plugin - to rotate towards another actors position, using only the yaw rotation, I assume there would be a node for this and will hopefully a quick fix, though i am not sure what the node would be. The second issue is about screen size and is a bit more nuanced. So, i shall input an image and then explain along the way.
I do not quite remember how i learned to subtract to get the right result, though, while this worked for a while, when i was extending the size of the details/outliner window, i noticed that the cursor actor was no longer on point with the mouse, and i couldn’t figure out how to fix this, i thought it had something to do with screen size, so i plugged in the get viewport size into the subtraction, and that was not at all the correct answer. I am a bit confused on both of these and would appreciate any help.
rotate an Actor toward a TargetLocation (this could be another actor, or an arbitrary point)
the vector that is currently pointing in the direction the actor is facing is the Actor’s ForwardVector which can be grabbed from the actor directly or the transform.
but really you will not be setting that vector, but rather you will be modifying through the Rotator on the Transform (either with SetActorWorldRotation or by directly assigning the value into the Actor’s Transform)
if you can get the Vector in the direction you want your actor to look VectorAB ( VectorAB = LocationB-LocationA) then call Normalize on VectorAB (because it is best to work with unit vectors as much as possible)
then you take the Actors current ForwardVector and VectorAB (this doesn’t need to be a cached variable, so you can just use the result of the normalized vector out of the subtraction) then you feed that in to the target of FindLookAtRotation() which is fed into the newRotation of SetActorRotation
for your screen size you have some very magic numbers there which would require your application into a very exact resolution (this is not a good practice), and this goes a little bit into how the screen is drawn, and particularly how the Game Viewport works with P.I.E.
in PIE the resolution of the viewport is dynamically determined based on your monitors resolution, and the size of the viewport relative to that resolution. you can see the “effective resolution” by looking at the Output Log while you are changing the size of your viewport (keep in mind this is technically an approximation, but it is “close enough”)
then point [0,0] for the application window shall be in the top left corner, with the bottom-right corner being (resXMax,resYMax).
the good news is that you can use GetMousePositionOnViewport() to get the X,Y location of the cursor (this is constrained by resolution, but should be meaningful). Keep in mind it takes a bit more work to figure out say “where is the mouse in world space?” or “is the mouse hovering over something?” for this you can use something like GetHitResultUnderCursorForObjects()