# How do i attack after reach destination

**URL:** <https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574>\
**Category:** Community & Industry Discussion\
**Tags:** move, attack, unreal-engine, question\
**Created:** [June 11, 2020, 11:29am UTC](https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574 "2020-06-11T11:29:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdmiralZheng](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AdmiralZheng](https://forums.unrealengine.com/u/AdmiralZheng)\
**Post date:** [June 11, 2020, 11:29am UTC](https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574/1 "2020-06-11T11:29:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [June 11, 2020, 12:21pm UTC](https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574/2 "2020-06-11T12:21:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AdmiralZheng](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AdmiralZheng](https://forums.unrealengine.com/u/AdmiralZheng)\
**Post date:** [June 11, 2020, 4:31pm UTC](https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574/3 "2020-06-11T16:31:08Z")

</div>

i tried, but it won’t, i’m using the movement system of Topdown Template. Using Set timer Event sometimes gives error Access none.

---

<div class="post-metadata">

**Author:** ![Rene\_Zwaan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rene\_Zwaan](https://forums.unrealengine.com/u/Rene_Zwaan)\
**Post date:** [June 11, 2020, 4:41pm UTC](https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574/4 "2020-06-11T16:41:07Z")

</div>

Hey Admiral Zheng,

Maybe Post a screenshot of your current AI system.

---

<div class="post-metadata">

**Author:** ![AdmiralZheng](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AdmiralZheng](https://forums.unrealengine.com/u/AdmiralZheng)\
**Post date:** [June 11, 2020, 5:09pm UTC](https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574/5 "2020-06-11T17:09:22Z")

</div>

@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

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/d/c/fdca15cb7fcdd96de545f561a605305c701ffc61.jpeg)

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/e/e6e39cb928718c1805082ce49c6c80ac040e23c2.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [June 11, 2020, 6:19pm UTC](https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574/6 "2020-06-11T18:19:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AdmiralZheng](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AdmiralZheng](https://forums.unrealengine.com/u/AdmiralZheng)\
**Post date:** [June 12, 2020, 11:44am UTC](https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574/7 "2020-06-12T11:44:58Z")

</div>

actually i want my Character attack exactly the one that i clicked on.

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/c/3/7c33b3b694dbde2fa79363707311efd7fe70f440.png)

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

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [June 12, 2020, 12:06pm UTC](https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574/8 "2020-06-12T12:06:10Z")

</div>

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.

 ![304238-moveto.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/c/b/bcb565078a095c9ac26b0fd9cd841c4a75a2aea5.jpeg)

---

<div class="post-metadata">

**Author:** ![AdmiralZheng](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AdmiralZheng](https://forums.unrealengine.com/u/AdmiralZheng)\
**Post date:** [June 12, 2020, 8:09pm UTC](https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574/9 "2020-06-12T20:09:22Z")

</div>

@ClockworkOcean: thank you so much i finally did it, now my character can move to target and attack it

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [June 12, 2020, 8:23pm UTC](https://forums.unrealengine.com/t/how-do-i-attack-after-reach-destination/466574/10 "2020-06-12T20:23:23Z")

</div>

Ha! Great 🙂
