I made a topdown game and simply wanted to make my character move to a target then attack (like other RPG game)
I can make it move to the destination with mouse control. But when i click on the enemy target, my character just moves to it, no attack after that so i have to click on the target again to check the distance to performe attack animation. How to make it move seamlessly?
Just move the code you have for the attack to right after the character reaches it’s destination.
The attacker knows which actor it’s heading for, so you can have a timer, checking the distance once a second ( for example ). When the target is within reach, attack.
i tried, but it won’t, i’m using the movement system of Topdown Template. Using Set timer Event sometimes gives error Access none.
Hey Admiral Zheng,
Maybe Post a screenshot of your current AI system.
@anonymous_user_7738aa03 Zwaan: Here is the blueprint, its kinda messy. Basically the branch node is just for checking range, after that just plays the animation, its too long so i can’t capture the whole thing in one picture
Maybe it’s some sort of turn based thing. But if it isn’t, it would be much better to just put the ‘move to’ directly on the ‘set destination’ node. So when you click that, the player just goes where it’s told
Then, separately on tick, do a sphere trace for nearby enemies. If you find one, attack it.
Because if you’ve got more than one enemy, and your player meets them halfway, it makes sense to attack them, and not the one you were heading for.
actually i want my Character attack exactly the one that i clicked on.
i tried to use Timer but it doesn’t work, it checked location of both the player and the target. But i think i’m heading the right way.
I created a collision sphere component on the Character to checking overlap status but these codes was writing in Player Controller BP, so i can’t access the collision component.
BTW Thanks for your help @ClockworkOcean
@ClockworkOcean: thank you so much i finally did it, now my character can move to target and attack it
Ok, specific target.
So when you do the mouse trace, you need to store the place you click so you know when you get there. You use the timer to wait until you are at that location, then attack.
Ha! Great