Best way to "shake" an object?

Get help using Construct 2

Post » Thu Feb 11, 2016 7:40 am

I want some objects to vibrate violently under certain conditions. (Imagine a screen shake function but it shakes an object and not the screen)

I also want those objects to vibrate but not go off track of their current positions. (Shake in position, not shake and go wildly off the screen)

The only way that I can imagine this working is something to do with randomized values and sine behaviors. My attempts at it are really not satisfactory. If anyone has done this before and gotten it to look good please help. I've never seen this topic covered enough.
B
20
S
5
Posts: 108
Reputation: 1,473

Post » Thu Feb 11, 2016 7:51 am

one way is you could save the object's x and y into instance variables, then just have a function you call that sets the objects Xs and Ys to random(saved.x-10,saved.x+10) and random(saved.y-10,saved.y+10). then just have it set the object back to the original position when you're done shaking. Does that make sense?
B
86
S
43
G
71
Posts: 601
Reputation: 43,609

Post » Thu Feb 11, 2016 8:08 am

Sweet! This is exactly what I needed to know, thanks. Works great.
B
20
S
5
Posts: 108
Reputation: 1,473

Post » Thu Feb 11, 2016 3:08 pm

@General J

You can also 'shake' an object by slightly offsetting its origin point.

example-
https://dl.dropboxusercontent.com/u/22173473/shaking.capx
B
21
S
6
G
8
Posts: 1,215
Reputation: 7,881

Post » Thu Feb 11, 2016 6:17 pm

@General J
You can use the Scroll To behaviour and every x seconds -> shake (power)
B
10
S
3
Posts: 272
Reputation: 1,360


Return to How do I....?

Who is online

Users browsing this forum: ColombageEnPLS and 6 guests