Animate based on line trace

Hello all,

I’m trying to make a system where a character holds a flashlight at their side and points it via animation toward the output location of a line trace. Ie, when a character is close to a wall, the light will be pointed up to point at where the characters is looking, and as the character walks backward, the light would be held slowly more level to continue pointing at the right place. Any idea how to make the animation work based on line trace?

Thanks!

It sounds like it would be easier just to follow the control pitch like weapons do in FPS template?
How is what youre describing different from aiming a typical fPS gun?

Well the difference is that I have the first person camera in the head which is no different from the FPS gun, but the flashlight is being held in the hand with a light cone in it. I need basically an aim offset for the flashlight to aim where my camera is. If i didn’t, when I stood close to a wall the flashlight would be pointed at the wall down by my hip and what I’m looking at wouldn’t be lit up.

oh you mean the flashlight is attached to the character’s hand on their third person skeleton so you need to get the hand to follow the camera so the flashlight points where you are looking?

Exactly! An aim offset of sorts.

I’m not sure what the best way is but I think you dont need a trace.
I think you could just add a scene component or a socket to your pawn’s camera, at a some distance away but attached so that it is always in the center of your viewport no matter which way you turn your head.

Then every Tick you can have the Flashlight or the Bone holding it rotate to the LookAt rotation from the flashlight to the scenecomponent. Or something like that.

I havent done anything with skeletal animations yet so i dont know how aimoffset works.
if aimoffset is some kind of float between 0 and 1 then maybe you can use my idea and get the dot product between the camera forward vector and that LookAt vector and use the result of that somehow.