# Sphere Trace Not Returning Hit

**URL:** <https://forums.unrealengine.com/t/sphere-trace-not-returning-hit/451828>\
**Category:** World Creation\
**Tags:** setactorlocation, unreal-engine, Physics, Collision, question\
**Created:** [July 7, 2019, 12:40am UTC](https://forums.unrealengine.com/t/sphere-trace-not-returning-hit/451828 "2019-07-07T00:40:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tisreece](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tisreece](https://forums.unrealengine.com/u/Tisreece)\
**Post date:** [July 7, 2019, 12:40am UTC](https://forums.unrealengine.com/t/sphere-trace-not-returning-hit/451828/1 "2019-07-07T00:40:12Z")

</div>

Hi guys,

So I’m having issues with some physics and collision in general and I have probably gone about my workaround completely wrong, but either way maybe you can help me out with that too.  
Bit of background on what I am trying to do, I have a projectile that I want to act like a boomerang, curves around and then eventually back to the approximate location it came from. Naturally, **simulate physics** is turned off for this kind of behaviour. I initially also had a **projectile movement component** , but getting the correct velocity just didn’t seem to work so I switched it up and did it all manually via **set actor location** each frame.

Because of this I am unable to get hit results if it hits a wall, therefore I have it looking for **overlap events** instead. Overlap events however, do not give me a **impact normal** to work with, so if overlap happens, I do a sphere trace with a pretty hefty search radius as smaller radii were producing very unreliable results. That being said, if the projectile come in at an odd angle, or gets stuck in a corner, the sphere trace produces no hit result, going straight through the object. As well as this, objects that have been scaled up never produce a hit result, such as the large rocks.

Is there any way to fix this?  
Or is there a better way of achieving what I am going for?

Thanks

I have attached a few images to show what is happening.

 ![281681-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/d/1/dd16cb396ba13802a9b867094387799a7e0cccc4.png)

![281682-capture2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/9/4/49426fc446a95610c01a8e2b58f9d44767cfe032.png)

![281683-capture3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/7/6/876bd5d442bce5c264e3d661ef5c901ad8e8d5b1.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:** [July 7, 2019, 8:38am UTC](https://forums.unrealengine.com/t/sphere-trace-not-returning-hit/451828/2 "2019-07-07T08:38:00Z")

</div>

> Because of this I am unable to get hit  
> results if it hits a wall

Try this:

- ensure the wall and the boomerang have blocking collision
- ensure the boomerang _is_ the root component - this is crucial
- tick _Sweep_ on the _Set Actor Location_ node

This should do 3 things:

- the boomerang stops immediately when blocked (even thought you keep ticking it and forcing its position!)
- it continually generates results _on Component Hit_, with normals
- since you manually _Set Actor Location_ every frame, this very node will also generate the above results - these are in the _Sweep Hit Results_ pin

* * *

This should work well without the need of additional sphere trace - unless you need it for something else, do tell.

edit:

With this method, you can keep the Simulation on and, as soon as the hit is detected, _stop_ manually updating via _Set Actor Location_, have the physics take over and let the object fall to the ground. If that’s what’s needed, that is.

---

<div class="post-metadata">

**Author:** ![Tisreece](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tisreece](https://forums.unrealengine.com/u/Tisreece)\
**Post date:** [July 7, 2019, 10:01am UTC](https://forums.unrealengine.com/t/sphere-trace-not-returning-hit/451828/3 "2019-07-07T10:01:44Z")

</div>

I am unable to use the mesh as a root as the mesh rotates, which messes with the movement as some of the BP uses local direction converted to world space to decide its velocity.

However, I tried it with a box collision (not ideal as I would rather some kind of custom collision to be my root) and the sweet hit on set actor location does work, but is more prone to getting in corners and odd angles.  
If I can get the sphere trace to return hits 100% of the time then I think this would never happen.  
One thing I might try is, if the sweep finds a hit on the same frame I feed it into another set actor location with sweep disabled, to ensure it actually moves.  
I’ll reply with any updates if I get it working.

Also keeping simulation on would not work, as editing the velocity manually to ensure it curls in the air and return to the player will not work with simulate physics enabled. Unless I’m misunderstanding, from what I’m aware manually editing movement of an object is not compatible with simulate physics.

---

<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:** [July 7, 2019, 10:34am UTC](https://forums.unrealengine.com/t/sphere-trace-not-returning-hit/451828/4 "2019-07-07T10:34:41Z")

</div>

> I am unable to use the mesh as a root  
> as the mesh rotates, which messes with  
> the movement as some of the BP uses  
> local direction converted to world  
> space to decide its velocity.

Understood.

> However, I tried it with a box  
> collision[…]

Was going to suggest that but nah 😉

> Also keeping simulation on would not  
> work, as editing the velocity manually  
> to ensure it curls in the air and  
> return to the player will not work  
> with simulate physics enabled. Unless  
> I’m misunderstanding, from what I’m  
> aware manually editing movement of an  
> object is not compatible with simulate  
> physics.

Keeping it off and only switching it on on hit might work here, I think.

> That being said, if the projectile  
> come in at an odd angle, or gets stuck  
> in a corner, the sphere trace produces  
> no hit result, going straight through  
> the object.

Not sure what’s happening here - trace starts inside a colliding volume? Perhaps you could continuously sphere trace along the forward vector of the moving object (with the radius close to the boomerang size) and monitor the distance between the mesh and the trace hit. Once the dist is close to 0, you’ve hit the obstacle.

So rather than waiting for the collision to happen, you know how close you are to it happening.

---

<div class="post-metadata">

**Author:** ![Tisreece](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tisreece](https://forums.unrealengine.com/u/Tisreece)\
**Post date:** [July 7, 2019, 11:27am UTC](https://forums.unrealengine.com/t/sphere-trace-not-returning-hit/451828/5 "2019-07-07T11:27:55Z")

</div>

A continuous sphere trace might be my best bet actually. I was worried about potential cost of doing this but, given the issues I have had with every other method it might be best.  
I’ll give some of these new ideas a go when I’m at my PC next and see what happens.

Thanks for help 🙂

---

<div class="post-metadata">

**Author:** ![Tisreece](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tisreece](https://forums.unrealengine.com/u/Tisreece)\
**Post date:** [July 7, 2019, 1:43pm UTC](https://forums.unrealengine.com/t/sphere-trace-not-returning-hit/451828/6 "2019-07-07T13:43:06Z")

</div>

![281734-capture4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/f/2/6f2da3a3f2b3bab747b2ac446a512aae3bccaf0b.png)

Even when called every frame the sphere trace often does not produce a hit. I have absolutely no idea why sometimes it does and why sometimes it doesn’t produce a hit.  
If this is a bug then I have no idea how it has gone unnoticed as it seems pretty major to me for there to be an issue with such a basic mechanic.

---

<div class="post-metadata">

**Author:** ![Tisreece](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tisreece](https://forums.unrealengine.com/u/Tisreece)\
**Post date:** [July 7, 2019, 3:35pm UTC](https://forums.unrealengine.com/t/sphere-trace-not-returning-hit/451828/7 "2019-07-07T15:35:51Z")

</div>

Okay I didn’t manage to fix the sphere trace issue. However, with a lot of trial and error teaching me vector math, I realised that actually a Projectile Movement component would do what I wanted.  
I’m going to upload the unrefined but working blueprints I have so far. I know for a fact, that with projectile movement I can get the ricochet effect I am going for via hit events.

> **[Projectile to Return to Player posted by anonymous | blueprintUE | PasteBin...](https://blueprintue.com/blueprint/ubh6-jsa/)**
>
> No description provided
