0 Favourites

How do I make an object shake?

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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

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

    Should be a bit faster than this.

  • 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.

  • set magnitude to the amount of pixels it should shift to the sides and period lower

  • Aw yeah! That's brilliant! Thanks much!

  • 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.

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
167 14,489
DMT2005's avatar
DMT2005
Unread sticky
1 Favourites
C2 Games made with CocoonIO
136 89,812
minhcuong's avatar
minhcuong
Unread hot topic
99 10,132
karshinkoff's avatar
karshinkoff