This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-04-07 08:47:45

dominoespizza
Scratcher
Registered: 2010-02-28
Posts: 10

how do you make objects bump away from each other

I am trying to improve one of my projects because it's absolute rubbish (see for yourself http://scratch.mit.edu/projects/dominoespizza/1199069) but I don't know how to make things move away from each other when hit. It would be helpful if the object being hit moved away at the same speed as the object hitting it. PLEASE help me!

Offline

 

#2 2011-04-07 08:56:16

silvershine
Scratcher
Registered: 2010-11-21
Posts: 500+

Re: how do you make objects bump away from each other

Before I post a script, I just wan't to clarify what you need.

You want a script that does this: When to objects hit each other, the go back the other way at the speed of the object it hit.

Offline

 

#3 2011-04-07 10:33:16

puppetadventurer
Scratcher
Registered: 2011-02-20
Posts: 1000+

Re: how do you make objects bump away from each other

thats actually pretty cool


3

Offline

 

#4 2011-04-15 14:53:25

dominoespizza
Scratcher
Registered: 2010-02-28
Posts: 10

Re: how do you make objects bump away from each other

silvershine wrote:

Before I post a script, I just wan't to clarify what you need.

You want a script that does this: When to objects hit each other, the go back the other way at the speed of the object it hit.

yes i do

Offline

 

#5 2011-04-16 06:35:44

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: how do you make objects bump away from each other

Yes.
I made a bounce block in BYOB. Depending on the direction, use this script with some previousX and previousY variables: [P.S. this is the version for Scratch]
if touching other object
set previousY to y position
set previousX to x position
point in direction [the opposite direction of the one you hit it at]
repeat until touching edge
move 240 steps
end repeat
if on edge, bounce
goto x: previousX y: previousY
end if

Offline

 

#6 2011-04-16 07:38:48

dominoespizza
Scratcher
Registered: 2010-02-28
Posts: 10

Re: how do you make objects bump away from each other

how should i set the previousX and previousY varibles

Offline

 

#7 2011-05-04 10:53:51

dominoespizza
Scratcher
Registered: 2010-02-28
Posts: 10

Re: how do you make objects bump away from each other

would it work if you did object 1 speed, object 2 speed, object 1 bouce and object 2 bounce as
variables for everything and got object 1 to set speed to 0, point away from object 2, make it move at object 1 bounce which will be object 2's speed and eventually slow down and vice versa

Offline

 

#8 2011-05-04 10:55:03

dominoespizza
Scratcher
Registered: 2010-02-28
Posts: 10

Re: how do you make objects bump away from each other

dominoespizza wrote:

would it work if you did object 1 speed, object 2 speed, object 1 bouce and object 2 bounce as
variables for everything and got object 1 to set speed to 0, point away from object 2, make it move at object 1 bounce which will be object 2's speed and eventually slow down and vice versa

thats if it hit object 2

Offline

 

Board footer