Make a flashlight shake while the player moves

Hello! So I’m testing things to create a horror game in first person. Currently I use Camera Shake for the head bobbing but I can’t find any solution to make the flashlight also shake.
Basically I want the flashlight to shake a bit when the player moves to make the movements more realistic, right know it stays static (only the camera shakes).

Capture d'écran 2024-02-11 200736
I started with the Third Person template and removed the mesh so the player is invisible. I then added two Spring Arms: one for the camera + the flaslight’s mesh and the other for the light (and both arms have camera lag with different values).

I tried to use Lerp, a Timeline, additions to Local Rotation of the flashlight but nothing worked and I can’t find anything online, it feels like it’s impossible to shake anything else than the camera in Unreal.
Can someone help me, please? :pray:

These are also what I were thinking about to achieve the shake movement .
Why didn’t they work,I’m curious.

EDIT:
Is it possible that you animated the wrong component?
Because I saw your hierarchy,the light is not a child of the flash mesh.
Did you animate the light?
I’m sorry if it is stupid.

I animated the spotlight, yes. The lerp worked for replacing the light in its initial position but to actually make it “shake” it’s beyond my knowledge. The Timeline won’t work because the timing is always the same and doesn’t look good, also when I add to local rotation I can’t put it back because I can’t set the local rotation.

I’ll show you code I use for realistic movement deviation in my game LANDNAV.

You wont be able to copy this code and have it work. But it does something similar to what you have described, so you can look at the code and once you understand how it is working, you can probably use a similar idea for your flashlight.

What this code does is add slight variations to the players control rotation while they are moving. With a very small value it is basically like the character “shakes” while moving. You can change the magnitude and frequency of the shake to suit your own needs.

The basic idea is that you are making this random float value that only happens while some condition is true.

For your flashlight that might be adding some random values to specific axes of the local rotation.

Here is the code:



Here is how we know when player is moving, you can check this on a timer or tick, or from your movement input:

and the guts of the Do While Special, a super handy macro:

1 Like

Mr. BIGTIMEMASTER made sense.

But if you want more,I could share some tips.

This node is how you can control the timing.(for example,set different play rate for walk run sprint )


And this is how to set local rotation.

Sorry,the pictures have some unrelated stuff in it,because I closed the computer,the pictures are I found from my previous question.