Sphere Trace Not Returning Hit

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.

281682-capture2.png

281683-capture3.png

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 :wink:

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.

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.

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.

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 :slight_smile:

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.

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.