Dynamic Lock-On? How?

Hi, this question is probably going to be a very difficult on the answer, but I was wondering if anyone know how to build an advanced dynamic targeting/lock-on system or any pointers would be great.

To more specific, I would like to build a dynamic camera system in which the camera would automatically adjust itself so both the player and the target can be seen very clearly. I’ve made my own targeting system, but the camera is fixated on the target and if the player is too close or there are too many enemies, it can be very difficult to see the targeted enemy. So I would like the camera to auto adjust itself by moving left, right, up, down, zoom in, zoom out, etc to make sure the player and the target is seen clearly at all times.

Reference Images:
3b-nier-automata (1)
devil-may-cry_5-balrog

I don’t expect any replies or answers on how to build a complex system like this, but if anyone is willing to share, I would really appreciate it. :pray::+1:
Thank you for your time!

If you have the bounding box for the player and the bounding box for the target, you should be able to find the bounding box for the area that needs to be visible by the camera at all times.

Then the hard part is doing all the math and adjustments so that the camera moves naturally, avoids obstacles, and is generally able to keep the target area on-screen at all times.

There are some GDC presentations that are worth checking out on how game cameras are implemented, for example this one about Journey is pretty great although I don’t think it goes into lock-on behavior: https://www.youtube.com/watch?v=C7307qRmlMI

Thanks @neofuturelabs!
I think I’m on the right track, I’ve have never heard of actor bounds, but I’ve have seen other dev use it and I thought they made it manually. I totally agree with you that math is going to be hard.

I couldn’t figure out how I can check to see if the target’s bounds are in view and aren’t overlapped by the player’s actor bound so I tried something more simpler. I used the target’s location and added a offset to it which works, but not around walls. I’ll need some more tweaking and fixing before it’s actually usable, but thanks for the reply it really helped.

1 Like