I been toying with this for a day now and couldn’t figure it out. I suck at vectors. Basically I want to keep my main character with an enemy lock-on but I don’t want the rotation on the enemy because of motion sickness. It only rotates once the enemy is out of screen.
I tried focusing the middle vector between the two but that didn’t help. A good example would be the Kingdom Hearts series. I just can’t seem to get the concept behind it.
I think I have some information to get you started.
First I want to say that I used some of the information in this [post] when creating my solution.
I will post my code and then explain it below.
So I posted this code in my character blueprint. The “Target” variable is just a public variable that I set in the editor. You could also set it via other methods like a line trace.
Basically this method gets the midpoint between the target actor and the character’s capsule component. This midpoint is then used to calculate a Rotator which is then sent it through a “FInterp To” node to smooth out the movement. Finally I set the camera’s rotation to this new rotation. This will always make the camera point at the midpoint.
A major disadvantage to this method is that the user can rotate the camera in such a way to hide the player character which obviously is a bad thing.
This definitely is not a perfect solution, but I hope it gets you on the right track,
Thanks for your answer. I have to test it out but for now what I did was get the distance between the mid point and the camera. Rotate the camera behind the player every time the distance was under 600. Also I had to attach an hidden actor to the midpoint for “get distance to” to work. It’s not as smooth but it doesn’t spin around too crazy.