# How can i set the projectile to go on the hit result of the SphereTraceObject?(self-guided projectile)

**URL:** <https://forums.unrealengine.com/t/how-can-i-set-the-projectile-to-go-on-the-hit-result-of-the-spheretraceobject-self-guided-projectile/456579>\
**Category:** Blueprint\
**Tags:** projectile-movement, unreal-engine, issue, Blueprint, question\
**Created:** [October 7, 2019, 7:48pm UTC](https://forums.unrealengine.com/t/how-can-i-set-the-projectile-to-go-on-the-hit-result-of-the-spheretraceobject-self-guided-projectile/456579 "2019-10-07T19:48:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SCIABI](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SCIABI](https://forums.unrealengine.com/u/SCIABI)\
**Post date:** [October 7, 2019, 7:48pm UTC](https://forums.unrealengine.com/t/how-can-i-set-the-projectile-to-go-on-the-hit-result-of-the-spheretraceobject-self-guided-projectile/456579/1 "2019-10-07T19:48:28Z")

</div>

Hi, I’m new on ue4 hand i have this issue…  
i want to build a self-guided projectile that goes on the first enemy near to it

when i use the TELEPORT node all is work fine but i can’t see the projectile path,  
instead if i try the MoveComponentTo i can’t even connect the return value of the SpawnActor.  
what should i do?

 ![289441-projectile-target.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/e/a/fea5c65e069d92f6409eb6e6c39b2e2590609419.png)

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [October 8, 2019, 3:03am UTC](https://forums.unrealengine.com/t/how-can-i-set-the-projectile-to-go-on-the-hit-result-of-the-spheretraceobject-self-guided-projectile/456579/2 "2019-10-08T03:03:40Z")

</div>

im assuming here that your aim is to fire a projectile that you can see in game and have it chase a player. if thats the case then i believe you are over complicating things a bit and theres a few easy options to get things working. in both cases we will make use of the projectile movement component and its homing abilities.

for the first option you could create your projectile actor add in the projectile movement component and with the movement component selected go to the details panel and check the box for homing and set homing acceleration in the homing section. next you could add collision component that is larger than the projectile which will serve as the radius checked for potential homing targets. from there you just need a simple script: on begin overlap, cast to target class (character, pawn, etc), and set homing target component (example below). with this you may need to make a check so the projectile doesnt chase the one that shot it though.

the second option works more like what you currently have. first you setup the movement component as above (first sentence of last paragraph). then you do the targeting work in your character by running a trace and using the hit actor in the trace as the target. i added a example of the script needed below though it would be placed in the character and not in the projectile as shown ( i was to lazy to add 2 pictures). again in this case i would add in a cast to ensure that your hit object was of the type you want to target before setting the homing target.

 ![289447-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/6/8/668345ccdcce04f1583de6de43b80cb7a6e9a699.jpeg)

---

<div class="post-metadata">

**Author:** ![MehrdadKM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MehrdadKM](https://forums.unrealengine.com/u/MehrdadKM)\
**Post date:** [February 29, 2024, 1:34pm UTC](https://forums.unrealengine.com/t/how-can-i-set-the-projectile-to-go-on-the-hit-result-of-the-spheretraceobject-self-guided-projectile/456579/3 "2024-02-29T13:34:30Z")

</div>

I know it’s more than a few years old, but I’d love to get my answer.  
Currently, I’m making a Tower Defense game and I want the projectiles coming out of tower to hit a single target (actor), which is moving along a Spline.  
I’m using the Homing feature and it works perfectly, as long as my target is stationary. However, once my target starts to move (either using Spline or a simple Projectile Movement), my Tower projectiles cannot hit it correctly. They miss their target, rotate around it, miss it again, rotate around it again, and finally they can hit it. What can I do to fix this?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 29, 2024, 2:08pm UTC](https://forums.unrealengine.com/t/how-can-i-set-the-projectile-to-go-on-the-hit-result-of-the-spheretraceobject-self-guided-projectile/456579/4 "2024-02-29T14:08:46Z")

</div>

> [@MehrdadKM](#):
>
> I want the projectiles coming out of tower to hit a single target […] They miss their target, rotate around it, miss it again

Do you want to them to **always** hit? If so, the PMC’s Homing Target is probably not the best choice since it’s in its inherent nature to provide a chance to be dodged. If you wanted extra accuracy, we’d need to factor target’s velocity, calculate lead and home in on that instead. But even if you did that, a rapid change of direction (90° turns are common in Tower Defence, right?) would still prove problematic.

* * *

Perhaps you need another, less realistic method. **Physically Accurate Projectile Simulations** may not mesh well with a TD game - do tell if that is _actually_ required. Or do we simply need to hit…

---

<div class="post-metadata">

**Author:** ![MehrdadKM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MehrdadKM](https://forums.unrealengine.com/u/MehrdadKM)\
**Post date:** [February 29, 2024, 2:57pm UTC](https://forums.unrealengine.com/t/how-can-i-set-the-projectile-to-go-on-the-hit-result-of-the-spheretraceobject-self-guided-projectile/456579/5 "2024-02-29T14:57:01Z")

</div>

Hitting the target is required.  
I tried manipulating the velocity vector of ProjectileMovement, instead of having Homing activated, but that seems not possible as I can’t feed the FindLookAtRotation to it.  
Then I tried adding a RotatingMovement component, but that didn’t work either as Projectile Movement dictates its own rotation over the RotatingMovement.  
At this point I think I should probably use a game controller and make my projectiles AI, but I doubt if that is a wise decision to have so many projectiles in the scene and all being AI.

---

<div class="post-metadata">

**Author:** ![MehrdadKM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MehrdadKM](https://forums.unrealengine.com/u/MehrdadKM)\
**Post date:** [February 29, 2024, 3:08pm UTC](https://forums.unrealengine.com/t/how-can-i-set-the-projectile-to-go-on-the-hit-result-of-the-spheretraceobject-self-guided-projectile/456579/6 "2024-02-29T15:08:49Z")

</div>

It seems like I finally made it happen!  
Instead of using the Homing feature, I simply created the ProjectileMovement vector myself.  
I used the initial location of my projectile and my target in the FindLookAtRotation. Then I extracted a VectorForward from its result, and multiplied Vector by a float to set the speed.  
Then, I set the resulting vector to SetVelocity, extracted from my ProjectileMovement component.  
The only thing is I did this in Tick, and I’m not sure if it’s optimized for all projectiles in the scene with different speeds.

 ![Screenshot (2085)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/1/f/41f56097779c517589c7742d1885a6dd3246372c.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 29, 2024, 3:12pm UTC](https://forums.unrealengine.com/t/how-can-i-set-the-projectile-to-go-on-the-hit-result-of-the-spheretraceobject-self-guided-projectile/456579/7 "2024-02-29T15:12:11Z")

</div>

Consider:

- skipping the PMC and `vInterpTo` to target (or the constant variant)
- skipping the PMC and Timeline `Lerp` to target (you could even dynamically spawn a spline and drive projectiles along an elaborate path)
- using the PMC Homing Target while also nudging it with physical forces (may not always hit, though)

Rotation can be obtained in many ways. For example: `Find Look at Rotation` using the projectile’s location from previous frame and the projectile’s current location.

* * *

If you want something truly performant, since we may be talking about 100s of projectiles\* (right?), look into Niagara.
