I know this should be simple but I am having a heck of a time wrapping my head around it. Maybe someone smarter than me can help.
I want to push my flying AI drone to face in the direction of a location. The pawn uses the same thrust system use by the player (axisup 1.0 means full speed look up, etc).
Once I have the Forward vector for the pawn and the direction vector for the target, what is the math to determine the -1 to +1 push value for pitch and yaw? I have tried several things unsuccessfully and I know I am missing something simple. The solutions I find involve simply rotating the actor, which I don’t want to do.
Hey @mmcmain
You can use FindLookAtRotation and split the rotation to use these values for your input. Your Start is your current location and your target is your location + direction. Then you would have to check how much pitch/yaw you can get like 10degree/1second with +1. So you would have to calculate how long you have to set an input to reach your target pitch/yaw. You could adjust these values (-1/+1) to reach pitch/yaw targets faster or slower.
Ok crap, I need to take my current facing into account. I guess I need to compute the relative rotation from my forward vector converted to a rotator? I will try that when I get back from dinner.
Hey @mmcmain
What happens if you use FindLookAtRotation and use SetWorldRotation for your Drone with these values? No lerp, no rotation over time , just direct input with the rotator. Which direction does your drone point at?
If I do that I get perfect orientation. So the rotator is correct. I just need to know how to use the value of that rotation to apply it to my current facing’s rotation through impulse rather than setting it directly.
This makes it align correctly. Thank you for your help! Confirming that LookAtRotation was the correct approach let me keep stepping on weeds until I found the roots.
I need to clean up the lerping a bit and dot product pitch and yaw separately to smooth it out and prevent overshooting, but this is definitely makes the drone point at the correct spot.