Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how do I make realistic bouncing?
- klobbo
-
11 posts
how do I make realistic bouncing?
Right now the script is:
This is ok, but it makes the object turn around instead of bouncing correctly, and everything else I've tried makes it turn around at some point. I want it to bounce around the screen somewhat like the dvd logo. How can I do this?
if <touching [Edge] ?> then
turn cw (180) degrees
end
This is ok, but it makes the object turn around instead of bouncing correctly, and everything else I've tried makes it turn around at some point. I want it to bounce around the screen somewhat like the dvd logo. How can I do this?
- NeonG4
-
1000+ posts
how do I make realistic bouncing?
In this case, couldn't the Right now the script is:if <touching [Edge] ?> then
turn cw (180) degrees
end
This is ok, but it makes the object turn around instead of bouncing correctly, and everything else I've tried makes it turn around at some point. I want it to bounce around the screen somewhat like the dvd logo. How can I do this?
if <touching [Edge] ?> thenbe switched for
turn cw (180) degrees
end
if on edge, bounceblock?
- platypus3333
-
37 posts
how do I make realistic bouncing?
An easy solution for a directional bounce is this:
foreverIf you want a straight bounce you could do this:
if <touching [ v] ?> then
point in direction ((direction) * (-1))
end
end
foreverYou can customize it to make faster or slower movement.
move (steps) steps
change [ steps] by (1)
if <touching [ v] ?> then
turn ccw (180) degrees
set [ steps] to [0]
end
end
Last edited by platypus3333 (June 12, 2023 20:12:44)
- NeonG4
-
1000+ posts
how do I make realistic bouncing?
This only works for verticle walls. An easy solution for a bounce is this:point in direction ( ((direction) * (-1)))
A horizontal wall with a direction of 91 would become -91, which still is on the wall.
- platypus3333
-
37 posts
how do I make realistic bouncing?
This only works for verticle walls. An easy solution for a bounce is this:point in direction ( ((direction) * (-1)))
A horizontal wall with a direction of 91 would become -91, which still is on the wall.
Your right! I had made a pong game and was thinking of what I used for the paddle and ball bounce.
- klobbo
-
11 posts
how do I make realistic bouncing?
In this case, couldn't the Right now the script is:if <touching [Edge] ?> then
turn cw (180) degrees
end
This is ok, but it makes the object turn around instead of bouncing correctly, and everything else I've tried makes it turn around at some point. I want it to bounce around the screen somewhat like the dvd logo. How can I do this?if <touching [Edge] ?> thenbe switched for
turn cw (180) degrees
endif on edge, bounceblock?
wow haha. I didn't even know that block existed. thanks!
- platypus3333
-
37 posts
how do I make realistic bouncing?
Actually, no. They do different things. The turn block sends it back to where it came from. The bounce block will make it change the direction by -1.In this case, couldn't the Right now the script is:if <touching [Edge] ?> then
turn cw (180) degrees
end
This is ok, but it makes the object turn around instead of bouncing correctly, and everything else I've tried makes it turn around at some point. I want it to bounce around the screen somewhat like the dvd logo. How can I do this?if <touching [Edge] ?> thenbe switched for
turn cw (180) degrees
endif on edge, bounceblock?
- NeonG4
-
1000+ posts
how do I make realistic bouncing?
Yes, you are very right. However: snip
1) The topic is resolved.
2) The “if on edge bounce” is what @klobbo was looking for, and not the “turn 180 degrees” block.
- Discussion Forums
- » Help with Scripts
-
» how do I make realistic bouncing?