Trying to create slight camera movements

So I’ve been creating a combat system for my game and I thought I’d implement some kind of camera shake when you attack. And what I’ve noticed when looking at my inspiration for this idea: The Strongest Battlegrounds (The Strongest Battlegrounds - Roblox). Is that the camera does actually shake slightly in the direction your character is attacking, but the direction the camera shakes to is actually relative to what angle your camera is looking at your character.

As can be seen in the video, when you punch to the left while viewing your character from behind, the camera sways to the left slightly, but when viewing the front of the character (which is the opposite perspective) the punch can be viewed as going in the opposite direction, and the camera actually sways in the direction of the attack instead of left.

I think this is really cool, but when trying to think of how I’d implement this into my own game I couldn’t really figure it out. Firstly, I’m not an expert on camera manipulation so I couldn’t really figure out how you’d even create a camera shake effect. I’ve tried using the popular EZ camera shake module, but to my understanding you can’t really control the direction in which the camera is shaking.

And then of course there’s figuring out how to change the direction in which the camera is shaking relative to the angle that the character is being looked at. My best guess would be some form of raycasting to check if the camera’s position is in front or behind the player, and changing the direction of the camera shake depending on that. I’m sure there are other, simpler, ways of achieving this, but due to my lack of knowledge on camera manipulation I can’t really achieve anything similar to the effect I’m trying to achieve.

2 Likes

Your character’s Humanoid has a property called CameraOffset which offsets the camera relative to the character. With that you could use TweenService or something to make the shake effect.

2 Likes

After trying your suggestion, it works. Thank you.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.