Weird distance problem

Hi,

in my project i am performing a line trace starting at the player camera and extending towards its forward vector. I want the player to interact with certain objects once the distance between the player and the object is below a minimum value. When I start the game the distance calculation is correct. But when I collide with the object(The object has physics enabled) and the object moves away from the player the distance calculation strangely doesnt work anymore. The calculated value is not the real distance between the player and the object. Below I have attached my blueprint script for performing the line trace. I hope somebody can help!

I think you’ll get a lot more joy doing the trace like this:


IE, from the character.

I tried it from the camera, it’s just a load of confusing rubbish…

I think the problem is the following:
The **Static Mesh which represent the Actor **has the same location as the Actor.
When you move the Object you don’t move the Actor. You move the Static Mesh instead.
In your case it returns the distance to the Actor location which doesent move.
So try the “Out Hit Distance” from the LineTraceByChannel Node instead to get the right distance.
Hope this will help you!

Hi, thank you for the tip! Now I understand what is going on.
Do you know how I can move the entire actor instead of only the static mesh component when I collide with it?

Maybe I can help you more if you tell me what you’re up to.
Why do you want to move the entire Actor?