Camera clipping breaks my line trace RESOLVED

Hey everyone, I set up a projectile with line trace but this breaks when the camera is clipped into an object. I need to change the start position of the line trace based on if it’s clipping but I have no idea on how to do this. Anyone with ideas?

Image 1: blueprint where line trace is created

Image 2: normal trace when not clipping

Image 3: trace goes wrong when clipping

Why even consider the camera and the boom in the equation. Surely you want to start the trace from the player?

How would you line trace from the player correctly?

The reason for using the boom is because I let the player zoom in and out the camera and this also changes the start of the trace. The reason for using the camera is because this way it would always offset correctly (crosshair is a bit to the right top of player).

Like this:

This is the result I get (so thats not centering correctly even when not clipping)

Hmmm… the forward vector from the mesh, does just point directly forward. And yet you have a line going off at an angle, not sure how you’re doing that :wink:

It should come out from the waist.

In the end, I’d use the head direction, I think that’s the good direction for the spell, but for now, it’s good to get the mesh working.

Can you show the code?

EDIT: Hold on, my bad…

Right, so it should be right vector for that mesh, never mind. You can also do it from the arrow ( or put your own arrow in to avoid the error you get ):

Got better results now, the only problem now is that the spell is not centered

346438-3.png

By centered, do you mean in that cursor I see?

How are you drawing that?

Yes correct I’m trying to make it cast to where the cursor / crosshair is every time. The crosshair is drawn in the center of the screen and is always fixed in that position

Then you might need to do some sort of projection from screen space to world space to get the end point of the trace. Take a look at:

346439-screenshot-6.jpg

I can’t look right now, but might be able to help later if you get stuck.

I got it working with this code! Is this good practise?

It looks very logical, well done :slight_smile:

Did you ever find a solution for the near object clipping? From the looks of it, this code still looks like it won’t resolve for when the camera passes into a nearby object.