How do I make an object shake?

Get help using Construct 2

Post » Wed Mar 11, 2015 7:28 pm

Hey. Would love to get enemies to shake for a second when hit by the player. I've seen it in a video, but have no idea how to do it. I think guy used the Scroll To behaviour, but when I use it, it just shakes the whole camera! Can anyone help?
Thanks.
B
7
S
2
Posts: 60
Reputation: 604

Post » Wed Mar 11, 2015 7:44 pm

you could use the sine behaviour, horizontal or vertical (or both with two sine behaviours) and small values for magnitude and period
on enemy hit ->stop movement,set sine active, wait 1 second, set sine inactive
B
38
S
11
G
5
Posts: 485
Reputation: 5,340

Post » Wed Mar 11, 2015 8:02 pm

If you want to do both vertical and horizontal shaking, use different period values for both. Otherwise, it'll just shake diagonally.

Image
Should be a bit faster than this.
B
8
S
2
G
6
Posts: 45
Reputation: 3,009

Post » Wed Mar 11, 2015 8:28 pm

Thanks for the replies. I'm a total noob to Construct, so I'm not really sure what I'm at. I've set the values like this, but it kinda just shifts the object a bit. There's no shaking. Sorry to be a pest.
Image Image
B
7
S
2
Posts: 60
Reputation: 604

Post » Wed Mar 11, 2015 8:33 pm

set magnitude to the amount of pixels it should shift to the sides and period lower
B
38
S
11
G
5
Posts: 485
Reputation: 5,340

Post » Wed Mar 11, 2015 8:39 pm

Aw yeah! That's brilliant! Thanks much!
B
7
S
2
Posts: 60
Reputation: 604

Post » Tue Apr 18, 2017 6:04 am

I'm doing this for a button and something I ended up doing was make sure that period and duration of the shake worked out so that the object would return to the original location instead of moving around slightly. (using large magnitude helped with testing).
But as far as I can tell it seems like even if you deactivate the sine in a different location when you reactivate it it'll continue where it left off meaning that it should never move more than the magnitude away from the original location so unless the exact location is important for some reason it should be fine to use any duration for the shake. Not sure if changing layouts or anything would break it.

Also apparently two 1 second waits and a single 2 second wait wait for different times or something.
B
17
S
6
G
1
Posts: 41
Reputation: 1,725

Post » Tue Apr 18, 2017 7:23 am

Maukka wrote:I'm doing this for a button and something I ended up doing was make sure that period and duration of the shake worked out so that the object would return to the original location instead of moving around slightly. (using large magnitude helped with testing).
But as far as I can tell it seems like even if you deactivate the sine in a different location when you reactivate it it'll continue where it left off meaning that it should never move more than the magnitude away from the original location so unless the exact location is important for some reason it should be fine to use any duration for the shake. Not sure if changing layouts or anything would break it.

Also apparently two 1 second waits and a single 2 second wait wait for different times or something.


You can also use the shake object behaviour

behavior-shake-not-camera_t166389?&hilit=plugin+shake

Download: https://rexrainbow.github.io/C2RexDoc/r ... hakeMod.7z
B
52
S
22
G
12
Posts: 725
Reputation: 11,716


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 6 guests