Discuss Scratch

Uniquename1
Scratcher
100+ posts

Finding intercept point for goalie

Making a soccer game I'm trying to figure out how to make my goalie purposefully go to the right spot to stop the ball. I'll work out how to not have him be a super computer goalie after that. I can know the balls starting position and direction of shot. I was thinking to somehow use y intercept, slope and y=mx+b but it's not necessarily crossing the y axis at the goal as they can shoot toward the top part for example. The specific direction is set though once the ball is on the way. Basically need to know the y position when x= -210 or 210 based on where it starts and the direction it is going. The game is here. Thanks.

https://scratch.mit.edu/projects/187007595/#player

The goalie also has to stay within y -30 and y +40 but I think I've got a way to do that when necessary and goalie doesn't change its x.

Last edited by Uniquename1 (Nov. 17, 2017 18:53:20)

deck26
Scratcher
1000+ posts

Finding intercept point for goalie

So if you can work out the equation of the line and you know the goalie's x value you can work out the corresponding y value. The equation of the line is all you really need and that can be easily worked out from the starting position and direction with a little bit of trigonometry.
gtoal
Scratcher
1000+ posts

Finding intercept point for goalie

Uniquename1
Scratcher
100+ posts

Finding intercept point for goalie

Yea I was hoping you guys would figure it out for me or it was obvious and i was missing something. Scratch's weird angle reporting with -90 doesn't seem to be helping. I suppose the angle will either be + or - and range between 0-180 as shooting either goal is going to be in one direction… Looks like it's going to be a sin, cos, tan thing.? SOH CAH TOA… The Y value is adjacent and the top angle is 180- (abs)direction. So CAH is… I'll have to come back to this Monday or over the weekend.
deck26
Scratcher
1000+ posts

Finding intercept point for goalie

Uniquename1 wrote:

Yea I was hoping you guys would figure it out for me or it was obvious and i was missing something. Scratch's weird angle reporting with -90 doesn't seem to be helping. I suppose the angle will either be + or - and range between 0-180 as shooting either goal is going to be in one direction… Looks like it's going to be a sin, cos, tan thing.? SOH CAH TOA… The Y value is adjacent and the top angle is 180- (abs)direction. So CAH is… I'll have to come back to this Monday or over the weekend.
Sounds like you have the knowledge to resolve this but come back if you can't work it out. Forget about x and y initially, just work out how a right-angled triangle fits the situation and how the angle relates to that.
gtoal
Scratcher
1000+ posts

Finding intercept point for goalie

the way you've done your game - it's not unlike Pong.. so have a look at some pong games for ideas?

Powered by DjangoBB