Using cinemachine for a lock on system.

So far what I have come up with is to dynamically populate the target list in a Cinamachine Target Group component with the closest enemy and then using it in a virtual camera with it’s Aim set to Group Composer and it’s Body to a Framing Transposer that follows the main character. Now it’s not looking or acting the best, but all I want to ask is if I’m on the right track here and I just need to tweak the numbers

I think we’ll need a little more info here, like a detailed description of what you’re trying to accomplish. Screenshots and movies of results would also help.

Hey,
Sure here it goes. So this is my basic set up.
This is the state driven camera I’m using

Here is the target group component

And the Virtual Camera

The code that sets the enemy in the target group is as follows :

                targetEnemy.target = indicatorObject.transform;
                targetEnemy.weight = 2;
                targetEnemy.radius = 1;
                //targetGroup.m_Targets.Append(targetEnemy);
                targetGroup.m_Targets[1] = targetEnemy;

Here is a video of how it works :

https://www.youtube.com/watch?v=eGxdYm07tCs

What I want to achieve is a lock on system more akin to Bloodborne or Devil May Cry. I want a way to tell Cinemachine to keep the enemy indicator in the center of the screen and keep the main character in the shot as well. Tell me if you need more info

ok, if you want the reticle in the center of the screen to always be on your target then TargetGroup is definitely not the way to go. It will target the weighted center of the group, always. As soon as your player character is added to the group it will be ignored if it has zero weight, or shift the focus point if it has non-zero weight.

Have a look at this thread, it might give you some ideas: Best way to do Dark Souls- Style target Lock using Cinemachine?

1 Like