Discuss Scratch

s118234Elic
Scratcher
2 posts

Velocity

Hi, im trying to change the velocity on an object when it hits another object and i cant seem to figure it out?
supergamer10000
Scratcher
1000+ posts

Velocity

Hmm, can you provide a link to the project?
helloworldbyeworld
Scratcher
1000+ posts

Velocity

Try this script on the object that you want to change the velocity of when it hits another object:

when green flag clicked
forever
if <touching [object v] ?> then
change [x velocity v] by (how much you want to change x velocity by when it hits the object::grey)
change [y velocity v] by (how much you want to change y velocity by when it hits the object::grey)
wait until <not <touching [object v] ?>> // This prevents it from changing the velocity continuously
end
change x by (x velocity)
change y by (y velocity)
end
s118234Elic
Scratcher
2 posts

Velocity

supergamer10000 wrote:

Hmm, can you provide a link to the project?
https://scratch.mit.edu/projects/446418551
Thingied
Scratcher
1000+ posts

Velocity

So from reading the code, I'm assuming you want the rabbit to move faster every time it bounces off the fox? Should be simple enough. Just make the rabbit move X velocity steps so that the speed is controlled by the X velocity variable instead of a fixed value.

Last edited by Thingied (Oct. 10, 2021 03:29:59)

Powered by DjangoBB