Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » collisions :(
- PlasmicPulse
-
Scratcher
100+ posts
collisions :(
alright so im making a 3d pong game, tryna recreate the coolmath version. The problem is when the ball hits the border its supposed to bounce off of it but sometimes it glitches out and goes out of the border and im not too sure how to fix it, can anyone help? https://scratch.mit.edu/projects/908532211/
Btw dont mind the ball randomly changing directions, that supposed to happen
Btw dont mind the ball randomly changing directions, that supposed to happen
- cookieclickerer33
-
Scratcher
1000+ posts
collisions :(
If the smoothing scaling of the border lags it makies the ball not get hit by it because the border scaled past the ball in 1 frame
Last edited by cookieclickerer33 (Oct. 20, 2023 18:00:09)
- PlasmicPulse
-
Scratcher
100+ posts
collisions :(
If the smoothing scaling of the border lags it makies the ball not get hit by it because the border scaled past the ball in 1 framewdym?
- cookieclickerer33
-
Scratcher
1000+ posts
collisions :(
If the project lags then the border scaling jumps from 1 position to another. This position difference is usally so large that it skips over the ball before the ball can detect it. There’s not much you can do to fix this because that’s just the way scratch works. This only happens if it lags however and that’s not going to be very commonIf the smoothing scaling of the border lags it makies the ball not get hit by it because the border scaled past the ball in 1 framewdym?
That, and when the ball bounces it can face toward the border multiple times and move more into the border
Last edited by cookieclickerer33 (Oct. 20, 2023 18:10:21)
- PlasmicPulse
-
Scratcher
100+ posts
collisions :(
the first that you listed isnt really the problem, but the second thing is. I already know the problem im asking for the solutionIf the project lags then the border scaling jumps from 1 position to another. This position difference is usally so large that it skips over the ball before the ball can detect it. There’s not much you can do to fix this because that’s just the way scratch works. This only happens if it lags however and that’s not going to be very commonIf the smoothing scaling of the border lags it makies the ball not get hit by it because the border scaled past the ball in 1 framewdym?
That, and when the ball bounces it can face toward the border multiple times and move more into the border
- cookieclickerer33
-
Scratcher
1000+ posts
collisions :(
Trigonometry, let me see if I can find somethingthe first that you listed isnt really the problem, but the second thing is. I already know the problem im asking for the solutionIf the project lags then the border scaling jumps from 1 position to another. This position difference is usally so large that it skips over the ball before the ball can detect it. There’s not much you can do to fix this because that’s just the way scratch works. This only happens if it lags however and that’s not going to be very commonIf the smoothing scaling of the border lags it makies the ball not get hit by it because the border scaled past the ball in 1 framewdym?
That, and when the ball bounces it can face toward the border multiple times and move more into the border
- cookieclickerer33
-
Scratcher
1000+ posts
collisions :(
https://en.scratch-wiki.info/wiki/If_on_Edge,_Bounce_(block)
Go to “workarounds” then all you need is a way to detect if it’s touching the top or bottom, or left and right
Go to “workarounds” then all you need is a way to detect if it’s touching the top or bottom, or left and right
- AHypnoman
-
Scratcher
1000+ posts
collisions :(
I haven't looked too deeply at the code, so I could be way off. I'll also preface this by saying I haven't fixed it (Or at least, most of it), merely found the cause of the problem.
The first thing I found is that as the ball is not perfectly circular it can clip through walls when rotating. With that fixed the error seemed to be this:

A potential fix would be to prevent the ball from rotating away from the centre.
Apologies for the awful diagram and explanation I'm far too tired to be trying to debug :P
The first thing I found is that as the ball is not perfectly circular it can clip through walls when rotating. With that fixed the error seemed to be this:

A potential fix would be to prevent the ball from rotating away from the centre.
Apologies for the awful diagram and explanation I'm far too tired to be trying to debug :P
Last edited by AHypnoman (Oct. 20, 2023 22:26:03)
- Discussion Forums
- » Help with Scripts
-
» collisions :(


