don't click here

camera shake

DEEPYA!

Press Start Screen
Sep 20, 2022
1
0
6
24
Hey
I actually got a problem and i need a little bit of your help guys.
So the issue is that In sonic worlds engine, i need to know how to make the camera shaking, like when we hit/crash an object , Or when an object hits the ground or falls down or else, i want the camera to shake a bit, and then stops shaking after that
So, i need your help in this If you know how to make the thing i want, and I'll be so thankful!
 

Metalsonic3 // Jargonfox

Spring Yard Zone
Sep 5, 2017
59
69
108
31
Finland
I'm a biiiit late here and I hooope you've figured it out by now, buuut you're using Clickteam Fusion right? I'd add a shake like this, I haven't used Sonic Worlds in forever sooo I'll just give a general yet hopefully detailed description for what to do:

Basically, I'm gonna make a timer to tell the game how long the shake should happen for, a power value to tell how strong the shake should be, and another value that will either flip and flop between negative and positive of the power value or get set randomly based on the power, whiiiich will then get added to the camera's Y position.


Make a new value (counter, alt value, whatever you wish), name it "shake_timer" or whatever. Add an event to make it tick down if it's above 0.
Make another value, name it "shake_power". You may set this to 3 to 5 or anything else now.
Aaand another value, name it "shake_now". Add an event to set it to 0 if shake_timer is 0.

Time to add events:
shake_timer is above 0, and shake_now is 0 --- set shake_now to shake_power.

shake_timer is above 0 --- set shake_now to shake_now * -1
OR, instead of just flipping the value from positive to negative, you may do this to randomize things:
shake_timer is above 0 --- set shake_now to shake_power * -1 + random(shake_power * 2)

Next, find the event that sets camera Y coordinate (X also, if you want left to right shake. You might wanna do another shake_power and shake_now for X). Aaaand yeah, just add a "+ shake_now" to the end of the expression. If alot of math happens in the expression, just add ( ) at the start and the end, juuust to make sure nothing breaks, never hurts to do that. Might also wanna scan through the code and make sure there aren't multiple events for setting the camera position in different situations, old Sonic Worlds only had a single event for that but I'm not sure if things have changed.

Neeeext, to actually make things happen and shake when wanted, look up events where you want the shake to trigger, such as an object hitting the ground. Thooough for starters you might just wanna do an event like "Upon pressing A" just so you can test things faster. Anyway, hook up these actions to the moment of a shake, make sure these happen only once ("Only one action when event loops"):
--- set shake_timer to 10 (or 15, or 20, 30, etc, depends on how long you want your shake to be)
--- set shake_power to 3 (or 5 or 10 or whatever, again, depends on how strong you want the shake to be)

Aaand there you go, should work! Unless the camera is at it's topmost or bottommost position of the frame blocking some of the movement, but hey.

Oh and, you might notice that the shake is FAST since it triggers every frame (presumably at 60fps), if you want to slow it down you might wanna add something for the "set shake_now" events to make them happen less frequently. Easy and lazy way to do this is just to add a timer, such as "Every 00''-05" or something. Oooor if there's a general timer in the stage ticking, you might wanna try out something like "stagetimer mod 5 = 0", does mooostly the same thing as a timer but is more accurate in some situations.