Hello Roblox Devs!!
I want To create some Camera shake for my guns. I essentially have everything figured out except for camera shake and is something that I’ve always had difficulty understanding. I have no idea where to start. I have tried reading this article
but I had a hard time understanding and the video results were not to my liking. Can someone help me walkthrough the math involved with this and help me truly understand why it is and how (I currently know most of Algebra 2 and some trig)? I know I shouldn’t be reinventing the wheel as my cs teacher says but I want to understand rather than just copy and paste.
I am going to assume you know how tween service works, if you don’t, there’s plenty of good videos on Youtube and experimenting with it yourself is always fun.
Basically, things have points in 3d space along 3 axises, X, Y, and Z. This is captured in the Vector3 data type; this script basically chooses a random value from negative to positive shakeIntensity along those axises for a random offset to add to the normal placement of the camera. Basically choosing a random point in space around the camera itself. Then, the camera is tweened from it’s current position to the new position.
How long the camera takes to move to the new position is controlled by shakeSpeed. While, how far that random offset can be is controlled by shakeIntensity.
As for making it to your liking, I suggest tinkering around with those two values along with the TweenInfo assosiated with the camera tween. Easing styles such as quad can help.
I’ve noticed that some people have used sin(x). Is using trigonometry a better way to do this or should I just use random values in a specified intensity as you mentioned
Well, as with most things in coding, I can’t really say whether it’s better or easier; that depends on you. I don’t really do much with camera work, so I couldn’t say. However, it might make the movement seem more natural and smooth, since it is a wave.
I’ve just found an article that fits what I’m looking for! But obviously I wanna learn what’s happening here and why that is. Can someone explain to me what’s going on?