I’m currently working on a camera that’s at a 65 degree angle, but I want it to stay stationary if it’s too close to a wall. I found a video of something similar to what I’m attempting to do, but I can’t seem to get it to work well. The screenshots below show the code and the line traces. All I need is to figure out how to get the location of a collision and move the camera accordingly so it doesn’t look beyond the wall.
You got trace coordinates so you just need to calculate the distance between camera and traced location by using distance (vector) and the do something with length of the camera spring arm
Try placing the origin of the spring arm at the height you want the camera to be and then offset the camera in the XY plane with the spring arm.
I have used both of your methods in the past for one with 3 traces instead of the 13 shown, using the world location of the collision point and the world location of the capsule component and calculating the offset of the spring arm that way, but with multiple line-traces, as shown, it has proven to be more difficult. I’m thinking a potential fix could be using the collision locations of opposite traces (0 & 12, 1 & 11, etc.) and subtracting them from each other. I’m yet to test this and won’t be able to until 12 MST. I’ll return with results at some time afterward once sufficient testing is finished. Thank you for the ideas, but sadly they aren’t what I’m looking for.
Did you solve it? I have the same problem
As usual there is likely many different ways to do this. I would suggest a separate camera actor not parented to the player, yet, still moving as if it were. Then you could likely use some geometry (big cubes) hidden in game but colliding with walls in your map.