When i do my attack animations, i want my character to snap to the locked on target until they are dead or i dont use any attack animations at all. Is there a way to do this?
Hi @oAnubus! So just to get a bit of clarification on the question, are you asking how you could go about doing Z-targeting (Like older zelda titles) where you lock on manually and all of your attacks are influenced by the lock on, or are you speaking closer to soft lock systems like the batman or spiderman games where you don’t lock on per se, but when you swing towards an enemy it always homes in on them?
More like the soft lock ons system where you swing it would home in onto the enemies. I do have a hard lock on system as a place holder but i still wouldnt know how to go about adding that to what i already have.
So there’s multiple ways to tackle this, and all of them are respective to how your combat system is now. Many would find the direction you’re input is pointing to relative to the camera (you already do this with 3rd person movement), you can take it from there and either have a PawnSense attached (or just a ray to all enemies and get the closest and bias towards a direction), if there’s an enemy in the short range you set it to (or multiple) do a distance check for the closest one. From there all you’d have to do is move like you normally with however your character movement is set up and bam you’re golden. However without seeing how your combat system is set up, I can’t really give too specifics, but that is how I’d break it down on white board.
This is the way i use my animations for my combat but the actual code for damaging is in the animation blueprint. I’ve never used pawnsense before so i wouldnt have a clue on what to do with it ^_^;
Alright so here’s where it gets a bit more complicated. So let’s break it down into smaller problems.
We need to determine all enemies close enough to be snapped to.
We then need to determine where you’re looking (you already do this in your movement code)
We need to determine which enemy is the closest to you in the direction you are facing.
Then we need to move the player quickly to a location near the enemy (likely best called as a function while the animation is happening) as well as rotate the player as needed.
Each of these will have varying levels of complexity. The first one is as simple as doing a quick multitrace and then you get a list of enemies in range to be snapped to.