how to set up a lock-on system ??


Firstly, I’d just like to say, I am rather new to Unreal and I have looked around and found information on this question on the forums.

However, There seem to be no “tutorials” on how to set up a Zelda esq target lock on system using BP.

I have tried to follow the example set out in: Blueprint: Helpful BP Functions - Community Content, Tools and Tutorials - Unreal Engine Forums

But I cannot get it to work.

I know this may have been asked a lot but can anyone link me to a tutorial or point me in the right direction on how on how to achieve this?

Thank you

Just a thought (I have not done this before):

First use the Get Direction Vector, using your character’s location and the target’s location as the input.

Then, feed the result into a Rotation from XVector node. Grab your camera and pull a “Set Rotation” node off of it and feed in the result of the previous node.

After that, it’s simply a matter of how often you want to call it. You could do it on an Event Tick I suppose, though I dislike using it. I dunno… I’ll leave that part up to you :slight_smile:

I wanted to try this out to see if I could make something useful for you so here you go

This is a pretty simple script and I’m sure it could be improved a lot but I wanted to give it a shot. I have a boolean flag determining whether the player is targeting something or not (I know a lot of people are against bool flags, but I didn’t know how else to approach this). If the player IS targeting something, it toggles off the flag. If the player is not targeting something it runs the function that drives the targeting system. To start, it grabs all actors in the scene and throws them into an array. For simplicity’s sake, I grabbed the actor at index 0 (in this case it’s a sphere I have in the game). I’m sure this could be elaborated on in future iterations such as cycling through targets (changing the index being called from the array) or making a bounding box that only selects nearby targets. Then, we check if there is anything to target (checking if the array has one or more indices). If it doesn’t, nothing happens if it does, you can target what’s at the index you choose. Then there’s math, but it’s super simple. I think that find look rotation is probably easier than the way that Chumble chose to explain. Literally all it needs are the locations of the player and the target and voila! it makes a rotator for you! For simplicity’s sake, I only have the player rotating around the z axis. The flag is set for targeting and the rotation on the character is set relative to its current rotation. Looking out on the main character graph again, every event tick the function is called if the player currently has the istargeting bool flagged. I’m not sure if this is the most efficient way to call this repeatedly, but hey I gave it a shot, right? I only started UE4 last week so cut me some slack if something is messy.

similar thread here might help some…

Thankyou very much!!! I now have a great lock-on system

hey i wanted to say its working but i want for the camera to rotate to i mean the character locking on it but not the camera can you send or do something about it? give me tutorial or something like those images to do ty

Hi, I know this is very old. im also trying to create my own lock on system. But what are those blue nodes in the input action? I cant seem to find how you made them. Are they fuctions from the created input action?