# Thread: Need help with physics/math

1. ## Need help with physics/math

I'm working on a baseball game and in order for the AI to work properly I need to be able to tell where the ball will land based on its speed and direction. The problem is my bat/ball interface is completely physics based and doesn't use static trajectories like most baseball games so every time you hit the ball it could go anywhere (based on a number of factors).

Any ideas?

2. Well I wish I could help, but it would sure be a lot easier to do so if you provided information such as what program you're developing this game with, and what code language or interface you're writing it in. It would also help to see the mathematical formulas involved in your physics engine.

But based off what you've said so far, I guess your best bet would be to just redo the system to incorporate static trajectories. :/

Well I wish I could help, but it would sure be a lot easier to do so if you provided information such as what program you're developing this game with, and what code language or interface you're writing it in. It would also help to see the mathematical formulas involved in your physics engine.
Game Maker and the physics "engine" is mind numbingly simple, I just don't understand physics in general. Basically once the bat contacts the ball, depending on the timing of the swing and the bat's height vs the ball's height the ball will take off. There is no spin on the balls and there is only air resistance and no wind.

The rise of the ball is based on bat position, whereas the horizontal angle is based on timing. I could post up the exe if need be.

But based off what you've said so far, I guess your best bet would be to just redo the system to incorporate static trajectories. :/
My intent wasn't really to create a baseball game when I started this, but to simply emulate puwapuro/yakyuu spirit's batting system so that would go against the purpose of the project unfortunately.

4. State the factors you want to use, and I might be able to help. Also, i guess you want to know where it will land on an area, am I right?

Edit: Saw your last post now, I'll see if I can come up with something about the distance

SPOILER! :
, it shows the basic stuff. Realised that you can find all this, better explained than I could ever do on Khan Academy, and sure enough: http://www.khanacademy.org/science/p...le-at-an-angle

ask away if you need clarification on anything. Mechanics is not really my thing, but it's basic engineering stuff this, so even a teconomist such as my self should be able to help you.

5. You're looking to get a lot of math answers, Jubes. If you're using Gamemaker, this is something completely different, as the physics are more than likely calculated in that language, or in the format of the engine you're using. I've screwed around with a few physics engines in some of my games, and most of the time they offer rigid bodies, see if you can use those, and look for a few functions hinting at force, velocity, etc.

Meaning, if you can find those functions, you can give the ball a velocity, and the bat a force on contact, and take the ball's velocity and the bat's force into account. I'd try and figure this all out, but I'm shit at actual math, and haven't touched GM in about a year or so, lol.

Try asking this in the GMC forum too.

6. C'mon James this stuff is so obvious

7. I plugged in your number rubisko but game maker wasn't having it. I think it's because the built in speed variables are bad and when I did get it to work it went backwards on the X axis. Guess I have to switch over to static trajectories. I'll just have to account for a butt ton of results.

8. You don't just plug math into GM, bro. You gotta do it so that the framework understands it.

9. I did, son, but I was using gm's built in speed function cuz I never thought this would balloon into such a big thing and now I really don't feel redoing everything.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•