Hello I’m still very new to unreal and followed a tutorial on how to make a lock on system but the creator left out the target switching portion.
Any help is appreciated.
Hello I’m still very new to unreal and followed a tutorial on how to make a lock on system but the creator left out the target switching portion.
Hey @Hit5333 how are you? Welcome to the forums!
In order to replicate the exact same case, could you share with me the tutorial you followed?
In you share it with me I will be able to test the same code and provide a good way to add the “switch target system”!
I’ll be waiting for your answer ![]()
Hey @Hit5333 how are you?
I’ve been testing this and I found a way to do it!
First of all, you need to create the two inputs to use for this and add them to the IMC (I decided to use J and L but you can use whatever you want):
Then, go to your character blueprint and add the following two variables:

This step is to create this custom event, the one to actually switch enemies, adding an int variable as input (you can do it on the details panel):
In order to make the previos Event work, you need to add two little things to the tutorial’s “Engage Lock” event:
a) fist of all, add this branch just before the “add” node:
With the previos changes, the last thing you need to add is the input calls:
Make sure you put the right values for the “Direction” variable (1 for Next, and -1 for Prev).
And that’s it! It should work perfectly if you followed all the tutorial from the video and my indications!
Let me know if you need more help with this!
I’m fine and thank you so much I’ll get to this as soon as I can and let you know if everything worked out.
Hello hope your day is going well I got around to adding your indications and part of it works.I can switch to a new target but can’t switch back also I’m using a controller so don’t know if I need to make some changes.
Hello again @Hit5333 !
In order to diagnose your problem properly, could you share all your blueprint with me?
You can upload your blueprints here instead of sending screenshot if you want, but I need to see the complete BP to understand the problem!
I’ll be waiting for your answer!
I made a post called lock on system and my name or should i just copy the code and paste it here.
No worries, I think this is the post, right?
I’ll be checking it and let you know when I find a solution!
Correct and sure thing take your time.
Hello again!
Ok, the only problem i found in your code is in your “Swtich Target Actor” event.
You need to connect the “%” node to the “Set Current Lock on Index” node. Otherwise it will always be 0 and you won’t be able to switch enemies properly.
Check that connection and let me know if it works now!
Ok will do.
Ok yea it was that works perfectly thank you very much.Also can I replace my right thumbsick for the controls?
Hey again!
Yeas, you can replace the inputs! You will need to use only one input action (you can call it “IA_SwitchLockedEnemy”) with Value Type Axis1D (float) and then assign your corresponding thumbstick axis to the IMC:
After that, create the following variables in you character BP:
Then, you will need to replicate this code in your character blueprint:
And that’s it, you will have it working with you thumbstick.
Oh thank you just seeing this now.
Ok I don’t know if I did something wrong but it doesn’t seem to be working.
Ok nevermind got it to work thank you very much you were a big help.You’ll probably see more of me in the near future.