Setting aircraft pitch based on two vectors

I’m trying to get an aircraft to control its pitch based on its own vector vs the target’s vector.

This is what I want to do (imagine the aircraft is in 3D space and the thrust is at a constant speed). The aircraft should try to level with and face the target using pitch (Y Axis).

This is a basic blueprint of the inputs and outputs.

I’ve been working on this problem for a week using many different (and most certainly wrong) vector setups. I would seriously appreciate any pointers!

You can adjust the aircraft’s Y to line up with the target using lookat and interp:

Hi, I appreciate the response. This solution somewhat works, but it kinda doesn’t. The aircraft does adjust its Y axis to align with the target, but it doesn’t loop around once the target is behind the aircraft.

A solution that outputs the correct numbers to the actual pitch input of the aircraft based on where the object is relative to the aircraft would more likely have the effect I need.

What are you trying to do?

If someone is flying this craft, using pitch to get to a target behind you is nuts. Then you would use yaw.

The solution I gave you will always point the plane perfectly if you connect up the other pins, but you asked for pitch only.

Maybe I need some more info? :slight_smile:

Hi! I’ll try to illustrate the effect I need through a video -

Sunday Challenge: Physics Review and Basics of Flying AI - YouTube (watch from 55:00 to 1:00:00). That 5 minute section demonstrates adjusting the pitch input based on the position of the target even when the target is behind it… in Unity. I guess I need that exact effect in UE4.

The piece of code the guy puts in is not the whole story. He already outlined that AI is controlling the plane.

There are nodes to copy that code exactly, but it won’t have any effect I’m afraid, unless you have written all the other ‘AI’ to make the aircraft navigate.

Presumably, there is something in there to deal with the target begin behind, even when you’re only allowed to use one axis.

That makes a lot of sense. I’ve tried remaking that code exactly and it certainly doesn’t work at all like that. Do you have any idea what else might be dealing with the aircraft in the event the target is behind it? The full code for that specific aircraft was released publicly on Github (here - SundayChallenges/Aircraft.cs at master · brihernandez/SundayChallenges · GitHub) if that helps, but no worries if not.

Sorry, no idea. I’m assuming it’s non-trivial…