🥴👉Easiest Way to Add Target Locking System in your Game Like Dark Souls and Elden Ring ⚔ | Unity

preview_player
Показать описание
🔸 This video is about the easiest way to create target lock-on mechanics in the Unity game engine.
🔸 I have explained how to calculate the angle, height, and other kinds of stuff that will build up our system.
🔸 You are going to learn how to switch cameras and work with Cinemachine cameras to lock on the target.
🔸 How to get nearby enemies and create UI to indicate the current target.
🔸 How to download animations from Mixamo and fix animation issues.

🔹 To Calculate Angle: Vector3.Angle
float angle = Vector3.Angle(Vector3 from, Vector3 to);
This function returns the angle in degrees between the two vectors.

🔹 Physics.OverlapSphere
Collider[] enemies = Physics.OverlapShpere(Vector3 position, float radius, int layerMask = AllLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);
This function returns an array with all colliders touching or inside the sphere.

👉 Don't forget to leave a like and Subscribe to this Channel for "Games Creation" related content.

👉👉 👉 I will start providing assets and new videos to my supporters in Patreon, so please help me grow my page so that I can do this full time.

#gamefactory #darksouls #eldenring #game #how #tutorial #savrigog #targetlockon
Рекомендации по теме
Комментарии
Автор

Sorry, the idea is nice, but man you have to explain more stuff. You didnt say where to put the enemy Lock on script. The Enemy Lock on script suddenly requires the camera follow script. Which doesnt really work if you already have your own setup. The Title "Easiest way to add..." Is just straight up false. This is: "Watch me add lock on to my game".

Bln
Автор

For anyone having issues with the TargetLock camera, I found it easier to set the TargetLock camera to use Body -> "3rd Person Follow", and adjust the offset to be above (Y=2) and behind (Z=-2) my player. You can then dynamically set the LookAt to your enemy and it will do what you want (position behind player, centered on enemy). When I followed these steps, my TargetLock camera kept winding up in odd positions that made no sense, but this fixed it.

thebearup
Автор

Awesome video and well written code! Saved me a lot of time not having to make my own locking system :)

omle
Автор

For anyone experiencing issues trying to implement with your different setup. I had issues with the main camera. Instead of referencing in Start. Had to make a public Camera and drop the main camera in Inspector and reference it that way.

blablabla
Автор

sorry, but you never mentioned where to attach the Camera follow and lock on script in this "easy" tutorial.

spngebob
Автор

can you make tutorial by doing the same thing with unity 3rd person starter assets !

indiestudio
Автор

This is not a tutorial, this is just a devlog because you are missing half of what needs to be created for it to work. You will never know where some of the scripts need to be attached to and you will never know what is the deal with the Main Camera GameObject having a parented Follow Camera AND a Target Camera, making 3 cameras + a fourth one for the canvas... And the code is just thrown at you like this, not even in a demo scene to show anything...

ariexmachina
Автор

Nice video, but you are doing one thing that is poor Cinemacine practice: the Cinemachine cameras should NOT be children of the main camera. You should move them out.

gregoryl_unity
Автор

I getting blurry movement when enabling the second camera, does anyone knows how to fix that? I'm using HDRP and cinemachine.

TryHardStudio
Автор

is there a way to make a target lock on overlay that doesnt inject into a game but lock on to moving targets other than the player?

foehammere
Автор

How do I add smooth collision tho? Right now it goes through objects with framing transposer and with extensions it doesn't look good aka it loses track of character and just focuses on character

mk-
Автор

Man nice tutorial but didnt work for me dont know what i am doing wrong and didnt understand ur code zzz.... i am newbee soo still ty

tarunbc
Автор

Hey so I got the lock on to work but the only issue I'm having now is that the lock on Vcam is moving independently from the follow Vcam. So when I switch back and forth from lock on to not locking on, it transitions to each camera in different positions. Any ideas? Thanks!

blablabla
Автор

Thank you for this video! I understand the code fairly well I think, but I can't for the life of me figure out why the currentTarget is not being detected by the OverlapSphere. My enemy has the target layer "Enemy" and I've set the Target Layers in the EnemyLockOn inspector to "Enemy". Still doesn't want to get detected. My enemy has a collider on it. I see the Overlapsphere in the scene overlapping it. It seems most of your code relies on there being a currentTarget first, in order for any of the functions to run. Any ideas? Thanks!

blablabla
Автор

How do I make the lockon camera show the Lockon icon using HDRP?

israfel
Автор

Hi, i was testing your code on my project but in spite of is everything before my eyes correctly improved, then I'm not sure why my enemies if they're far away from where I started on Play Mode, they don't lock on. Just the one who's on the range to the beggining, besides the weird thing is, if I let the enemy from the beggining following me until I'm close to another enemy, it lets me to lock on that Enemy too.

Only on that situation, what could be the problem?

XZypherX
Автор

can you show how to make it using playmaker without coding

peacelove
Автор

Hey! Nice video, just one question. There is a way to change the target with mouse moving? Like, move the mouse to the right, so, change target to the next one to the right

lucafernandez
Автор

Muy muy buen tutorial! esta perfecto y muy pulido, aunque en el video tutorial faltó explicar mejor que los enemigos devén estar en una Layer llamada Enemy y tener el tag también más una capsule collider, del resto está perfecto! me encantó el resultado! haré que mis amigos de habla ispana te den like! mereces mas likes y sub pro!

gustavovela
Автор

I attampted this with URP but i couldnt get the UICanvas dot to appear on top of the screen. Any advice with that would be great.
Great tutorial and thanks I was otherwise able to use parts of this to build my targeting system.

rwells