Discuss Scratch

kittyje1
Scratcher
83 posts

Rolling over obstacles

Hey I need help with a ball rolling over obstacles. Like this:

3 ____4
/ \
/ \
/ |
2| /
\ /
_________________1\______/5____________

It needs to go until it reaches point 1. At that point it will go up and backwards. Then when it reaches point 2, it will go straight up for a while then start to go forward and up. When it reaches point 3, it will go around the corner (still touching) and go straight forwards for a while. The corner is a place where i get stuck. When it reaches point 4, then it will go down and forwards, then go straight down, then go down and backwards. When it reaches point 5, it goes forwards again. Needs to be touching the shape the whole time.

For a tree-shaped shape, it seems that it gets stuck when it reaches the tree (w: 81 h: 171). The ball is 2.5x the height of the tree (radius 217px). Other shapes include: rectangle (w: 50 h: 266.25) scratch cat (h: 3) person (h: 5.5) and that shape up there.

Note: This is a Rolling Sphere calculator.
NMario84
Scratcher
1000+ posts

Rolling over obstacles

Do you mean you just need a ball to travel along the ground containing obscure shapes?
kittyje1
Scratcher
83 posts

Rolling over obstacles

NMario84 wrote:

Do you mean you just need a ball to travel along the ground containing obscure shapes?
Um…
Yeah.
But this is simulating an actual ball roll. It has to touch everything it can touch. I tried bringing it down until it touched the ground or an obstacle, but after the bend 4.5 on the diagram, it wouldn't touch point 5. It would just skip that part. So I am trying to actually roll it now.
NMario84
Scratcher
1000+ posts

Rolling over obstacles

The way I simulated it was to have a hitbox to check for collisions on the ground. Then I had another square box to check for when it goes off the course. I'm not sure how “accurate” you want the ball physics, but I had a similar question some time ago for how a certain weapon works from Mega Man.9. Specifically, the plug ball movement. It has a similar movement of a ball running across uneven ground.

You can take a look at it if you want. Maybe there can be a different setup for what you need.
https://scratch.mit.edu/projects/875203369/

Last edited by NMario84 (Sept. 13, 2024 21:32:46)

kittyje1
Scratcher
83 posts

Rolling over obstacles

NMario84 wrote:

The way I simulated it was to have a hitbox to check for collisions on the ground. (snip)
You can take a look at it if you want. Maybe there can be a different setup for what you need.
https://scratch.mit.edu/projects/875203369/
It needs to be really precise. As in actually rolling a ball. At least it's 2d. I already have trignometry to figure out exactly where it's touching (returning nothing of not touching) but i don't know if it's touching. If i need trignometry to figure out where it's touching, then what about if it's touching? I have a loop, but look at the original post:

I wrote:

When it reaches point 3, it will go around the corner (still touching) and go straight forwards for a while. The corner is a place where i get stuck.
GamesReinvented
New Scratcher
100+ posts

Rolling over obstacles

It'd be best if you shared your project and linked it here so would could see what we're working with rather than guessing at a solution.
EpicGhoul993
Scratcher
1000+ posts

Rolling over obstacles

kittyje1 wrote:

to figure out exactly where it's touching (returning nothing of not touching) but i don't know if it's touching. If i need trignometry to figure out where it's touching, then what about if it's touching?
????????? Like, what? You can only know where it's touching when it is touching something. What do you mean?

Anyway, I don't think knowing where the ball touches really help in this situation. You need to know if it's touching, and move accordingly. To do this just loop through the directions the ball can go, and attempt to move for every direction you find.

Here's my attempt at this problem.

————————
Now that I've gone through 2 topics of yours about this project, I think you need to reconsider your main idea and planning. Ask yourself some questions whether or not your project needs this feature or that feature, for example “do I need to know the point of collision if my really big ball is just rolling left to right?”. Like, try to stay simple, do not complicate things up that much.

Scratch on.

Powered by DjangoBB