Discuss Scratch

QuantumSevan
Scratcher
100+ posts

How to make an object vibrate?

How would i make an object vibrate a few times when it receives a broadcast message? I'm using this because i'm having a multitude of small explosions appear on a boss (mothership) when it is destroyed, and I want the mothership to vibrate each time an explosion appears. Maybe a custom block so that i can increase intensity of a vibration? Any ideas?

Last edited by QuantumSevan (Feb. 26, 2017 03:39:06)

miniepicness
Scratcher
1000+ posts

How to make an object vibrate?

repeat (200)
change x by (10)
wait (0.1) secs
change x by (-10)
wait (0.1) secs
end
QuantumSevan
Scratcher
100+ posts

How to make an object vibrate?

Well i kinda meant a quick vibration in any random direction then returning to original position
duckboycool
Scratcher
1000+ posts

How to make an object vibrate?

when I receive [ v]
repeat (Amount::grey)
glide (.2) secs to x: ((x position) + (pick random (-5) to (5))) y: ((y position) + (pick random (-5) to (5)))
end
You can change the numbers a bit.

I used to be active on the forums, but I have mostly moved past Scratch. I still do check my Scratch messages, so if you'd like to talk to me, just leave a comment on my profile. My main project on Scratch was Cookie Clicker, but my newest project is Snake Snake, a game based off of Snake, but with two snakes, and you can play either singleplayer or multiplayer.

QuantumSevan
Scratcher
100+ posts

How to make an object vibrate?

yoshifan509
Scratcher
100+ posts

How to make an object vibrate?

repeat (200)
change x by (pick random (10) to (25))
change y by (pick random (10) to (25))
end
Hope that helps (and works)!


S - Scratchers
H - Help
S - Scratchers
A scratch-based organization where scratchers help other scratchers.
QuantumSevan
Scratcher
100+ posts

How to make an object vibrate?

Hmm. But how would I make an object shake from side to side quickly, and then stop… and the intensity is how far the object goes from its original x position? kind of like a quick vibrate, then stop, then slightly more intense, then stop… and so on.
duckboycool
Scratcher
1000+ posts

How to make an object vibrate?

when I receive [ v]
set [intensity v] to [5]
repeat (20)
glide ((2) / (intensity)) secs to x: ((x position) + (pick random ((intensity) * (-1)) to (intensity))) y: ((Y position) + (pick random ((intensity) * (-1)) to (intensity)))
change [intensity v] by (.1)
end
It is the same as X for the cut off part.

Again, change the numbers some.

Edit; Also, you said side to side. If you just want X movement, replace the Y side with (Y position)

Last edited by duckboycool (Feb. 26, 2017 04:16:13)


I used to be active on the forums, but I have mostly moved past Scratch. I still do check my Scratch messages, so if you'd like to talk to me, just leave a comment on my profile. My main project on Scratch was Cookie Clicker, but my newest project is Snake Snake, a game based off of Snake, but with two snakes, and you can play either singleplayer or multiplayer.

keme6206
Scratcher
33 posts

How to make an object vibrate?

The code segments using random numbers above are not guaranteed (not even likely) to return the object to original position. To accomplish that, you need to intermediately store some values.

To use x- and y-distance for determining direction, but controlling shake magnitude independently of distance, you can use the code below. The object will end where it started. You need two variables defined: xshake and yshake.
define shake (dx) (dy) (level)
set [xshake v] to ( (level) * ( (dx) / ( [sqrt v] of ( (dx) * (dx) ) + ( (dy) * (dy) ) ) ) )
set [yshake v] to ( (level) * ( (dy) / ( [sqrt v] of ( (dx) * (dx) ) + ( (dy) * (dy) ) ) ) )
repeat (3)
change x by (xshake)
change y by (yshake)
wait (0.02) secs
change x by ( () - (xshake) )
change y by ( () - (yshake) )
wait (0.02) secs
end

Last edited by keme6206 (Feb. 26, 2017 04:20:24)

duckboycool
Scratcher
1000+ posts

How to make an object vibrate?

That wouldn't speed up (which they asked for), and would happen instantly rather than what I'm doing with gliding.

I used to be active on the forums, but I have mostly moved past Scratch. I still do check my Scratch messages, so if you'd like to talk to me, just leave a comment on my profile. My main project on Scratch was Cookie Clicker, but my newest project is Snake Snake, a game based off of Snake, but with two snakes, and you can play either singleplayer or multiplayer.

drmcw
Scratcher
1000+ posts

How to make an object vibrate?

Flabiothekite
Scratcher
1 post

How to make an object vibrate?

thanks
deck26
Scratcher
1000+ posts

How to make an object vibrate?

Flabiothekite wrote:

thanks
No need to necropost just to say thanks - all it does is bring an old topic back to the top page.
_A_T_O_M_I_C_
Scratcher
6 posts

How to make an object vibrate?

asa
aa
sa
sa
s
a
s
a
s
a
ss
Abigblueworld
Scratcher
500+ posts

How to make an object vibrate?

Oh! Here is HOW YOU DO IT!
when this sprite clicked
repeat (1/400)
go to x: (pick random (-3) to (3)) y: ((pick random (4) to (-4))
end
Hope this helps ^^

, Abigblueworld! :D
Girl,_ Gamer,_scratcher,_ BALDI/Uglydolls FAN,_ Former GD player and Roblox player!
GD: GDABIGBLUEWORLD
ROBLOX: GDABIGBLUEWORLD and Hitormissgonnamissya
ABIGBLUEWORLD 2019-2020 all stuff free to scratch. :)
SCRATCH ON!
-FavAnimations-
Scratcher
2 posts

How to make an object vibrate?

Is there any possible way to actually make the device vibrate?
-FavAnimations-
Scratcher
2 posts

How to make an object vibrate?

Because I kinda want to make the device vibrate in my hands for something

Last edited by -FavAnimations- (Aug. 20, 2020 16:09:33)

Vibrato
Scratcher
1000+ posts

How to make an object vibrate?

Please stop necroposting. If you want help you should make your own topic. Thanks.

I understand about indecision

Captain Disillusion wrote:

In software development, deleting, it's just a concept. Some software might have a delete button and when you click it a thing disappears, but it's not really gone. Okay, it's not gone from the memory.




fdeerf wrote:

chances are nobody will find your account, so nobody will follow you.



Za-Chary wrote:

I'm going to close this suggestion as it is technically implemented and rejected at the same time.
DaffodilYak
Scratcher
24 posts

How to make an object vibrate?

I think I found something a bit simpler
define 
change size by (-75)
wait (.01) secs
change size by (75)

Powered by DjangoBB