Why is Line Trace still detecting objects in a position, after they've moved away?

So I’m trying to do a line trace, on an object within the player’s components. Basically, my player-pawn is a cockpit for a VR player, with a holographic UI system inside, that I need to line-trace on to tell if the player is looking at it.
Once the player is looking at it, they can spawn little cube actors onto and attached to that 3D holographic UI, which I use as references to build a scaled up structure later.

The problem happens when the player starts Rotating that UI around. It’s a 3D structure which they can place cubes into, so the player needs to be able to rotate it around, to see all sides. When it rotates, cubes that were already placed on it, rotate with it, and I need to be able to detect those cubes too, in order to build on top of them.
I got this working, mostly, except when the player rotates the build-space-component, the Line Trace I’m doing starts detecting invisible hit collisions, where the cubes used to be, before I moved/rotated them away. It’s as if they’re leaving invisible ghosts behind, once I start rotating things… The objects seem to separate from their collisions, once I start moving them, as if they’re stuck in Static mode…

I’m not sure if I’m doing something wrong, or if I’ve just encountered an odd bug…

Can you please post a screenshot of your trace setup, if you don’t mind?

have you already tried the debug mode of the ray cast? it makes the ray and the target it hits visible and should help you to find the invisible boxes you are hitting.

Yeah, I’ve tried that. And I also have an “aim dummy” component, which I use to figure out some relative vector math later, but it also shows the Impact Location every tick if I make it visible, and I can see where the invisible boxes are, no problem. But I don’t understand WHY they’re happening… It’s as if the objects are staying in the same place, I can trace the invisible object all around itself, and it matches exactly where the blocks were, before I moved/rotated them away. What could possibly make an object separate from it’s collision like that?

Why do you add the impact normal to your aim dummy? It moves it away from the exact impact point. and why dont you start your trace at the camera but 10 units behind it?
but in general the ray trace does not seem to be the source of your error.

First of all I would suggest going to Project settings → Engine → Collision and create some new Object Channels and assign them to your Cubes and to your 3D Structure so they don’t use the same channel which now is World Dynamic. That will make your life much easier.

Create a different trace for the 3D Structure and another for your cubes, derived from the same command line.

I believe that the fact that both (Structure and Boxes) are using the same channel, it confuses the trace believing the boxes are still in place when they have actually moved.

I use the same mechanic when I look at a an item but I want to detect if it has a placeholder (which is another mesh) I want to attach items to. The first trace detects if I trace a placeholder, if true I set it to a bool, that is all. From there I continue with my normal trace, the one with all the scripting.

Something like this (sorry for the separate images)

That way the trace can ignore the first mesh (the 3D Structure) and trace the boxes once they have moved behind it.

cool i did not know of this. thanks for the tip!

Of course you will have to fiddle around with some Branches and some bools to get the logic to work so that the engine can distinguish between the two channels. But custom channels are very powerful once you get the hang of them. I hope it will help you.

Is it me or is the tower made up of 4 boxes but only the 3 rotate and the 4th remains where it was?

Well, I wanted the aim-dummy’s location to be raised slightly above the surface of the actual impact hit, and that’s how you do that. It just makes grid-rounding easier to figure out in my mind. Don’t think it would cause a problem…
And the trace should be starting 10 units in Front of the camera, no real reason, but I didn’t want to deal with ignoring a head-model if I stick one on the player HMD later. I can always just set that to the camera location exactly. But that shouldn’t matter either I wouldn’t think. :confused:

Interesting suggestions. Thanks!

I’ll try creating the different object channels, and using 2 different traces, asap.
If it works, I’ll be sure to let you know! :smiley:

another way to debug would be to print the names of the objects you hit. it can be done like this:

Is it really necessary to have 2 separate line-traces tho?
I’ve put my blocks and structure into their own channels now, although a Line Trace supposedly can detect more than 1 object channel in that object type array… So far I’m still seeing the bug… But I haven’t made the second line trace yet.
Also, just for good measure, here’s what the bug looks like when it happens:

First I make a little tower of blocks.

Then I rotate the structure 90 degrees left with a thumbstick…

After rotating the structure, and moving my head back to view where the tower was, my Aim-Dummy hits an invisible tower, as if the line trace is still detecting it there, even tho visually I can see the tower has been rotated away.

ALSO, the rotated tower has no collision at all anymore, and I can’t even place blocks on it, or get the aim dummy to acknowledge that it’s even there. It’s as if the collisions have separated entirely from their blocks.

Oh woops no… heh, The top block is a Highlighter block. It lets the player know where they’ll be placing the next block, based on where they’re looking. It moves aligned to a grid (locally aligned to the structure) for placement. It’s also based off the AimDummy’s position (the white sphere, which is normally invisible), and I use it’s positing to help position newly spawned cube actors. It moves around where the player looks, in response to the Line Trace data.

It’s floating in mid-air, because the Line Trace is detecting that tower’s collision still there… So it wants to place new blocks floating up there, but Obviously that’s not right. lol

Maybe the error is not in the trace but how you deactivate the highlight. Seems to me that once the highlight is turned on, it doesn’t turn off.

Ok, try to disable collision of your boxes while you move/rotate them and enable it again when they finish moving. Maybe that will refresh the colliders.

Hmm… The highlighter doesn’t really interact with much, it’s just based on math coming from the Impact Point/aim dummy… And everything else that uses that math from the line trace, also is detecting this weird collision. If I turn on the Line-Trace Debug, it collides with an invisible tower too. And it doesn’t detect any hit at all, on the real tower that I rotated away, like it’s not really there.

That’s another great idea! :smiley: I’ll give that a shot. Thanks for the help!

Also, it’s not the easiest to understand, but here’s my weird math for the Grid-spawning, and Highlighter/Placement Cube behavior. I get the relative transform, because they’re parented to the structure already, cause I couldn’t figure out any other way to convert the local/world math. heh

Maybe I’m just forgetting something simple. The integer math at the bottom is for aligning things to a grid of 50 relative units.

Mind bending :slight_smile:

Have you thought about using custom depth for the highlight instead of triggering visibility?