I have a Paper2D.PaperCharacter Blueprint, in the components section there is a Sprite. I’m looking to get the sprite to always face the camera/player. I have managed to get this work partially but only when my character starts face on the to the sprite initially, is there a way rotate the forward vector of the component sprite so that it always faces at a right angle to the player?
I was just thinking about looking into this last night …but I’m using C++ Not sure how much a C++ answer would help you, but if i figure it out, I’ll post it anyways
EDIT: (I’m still going to find it out in UE4/3D)
I found this in an old 2D shooter I made(not UE4 though but should be similar):
//a = main sprite b = what "a" looks at
float xsaver = b->movex - a->movex;
float ysaver = b->movey - a->movey;
float angle = atan2f(ysaver, xsaver);
a->rotatex = angle;
the rotate is radians though so you have to change it to degrees
either by
FMath::RadiansToDegrees(angle); /
or
angel * 57.2957795
Thanks for the great reply, looks very interesting and similar to some of script I’ve been seeing up with the “Find look at rotation” node. I have an AI programming friend who is helping me with this so I’ll get him to check this out and let you know what we find
I made this for shooting a bullet at someone, so you’ll just want to feed the final rotation vector into a SetWorldRotation call. You may want to lerp it as well if you want a slow turn vs an instant turn.