Change Spring Arm angle not length on collision
The issue I'm running into is I would like to have the spring arm on "collision" check not to change its length but to just rotate to compensate for the collision. Then once the player moves away from the collision it should return to the default spring arm angle I have defined. Here is a picture illustrating what I'm talking about. I cant seem to get the spring arm from changing its length. Any insight would be great!
asked Aug 18 '14 at 08:53 AM in Blueprint Scripting
You might consider using a couple of Line Traces instead of collision detection. I created a basic setup using line traces that works pretty well for me, though it is certainly not perfect and could be improved upon.
Here's the Components tab of the MyCharacter BP:
Pretty standard, except I added a small Sphere component and named it CameraCollision, then attached it to the Camera and moved it down a bit.
Here's the Event Graph:
First, we set a Rotation variable based on the Camera Boom's World Rotation. This gives us an angle to return to when nothing is blocking the trace.
Then we perform our first trace, a Single Line Trace by Channel, with the Start Location of the Camera and an End Location of the Mesh component. If the trace hits something, we rotate the Camera Boom by 1 in Pitch. It will continue doing this per Tick until nothing is blocking it. This may need some additional clamping if you have a ceiling, etc.
If the first trace doesn't hit anything, it performs a second trace between the slightly lower CameraCollision component we created earlier and the Mesh. This second trace is giving us a bit of a cushion before returning the rotation to its initial position, so it doesn't jitter wildly between rotating up and rotating down.
Once the second trace is also returning false, we start rotating the Camera Boom back down to its initial rotation.
There's still some jitter with this set up that can probably be cleared up with some adjustments to the rotation speeds and positioning of the components, but you get the general idea.
Hope this helps!
answered Sep 24 '14 at 10:48 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here