Advertisement

Knowing position of object ahead of time

Started by July 12, 2012 12:31 PM
2 comments, last by alvaro 12 years, 7 months ago
[color=#323D4F]Hi all

[color=#323D4F]In games Like FIFA or Pro Evo Soccer when the ball is in the air after being kicked, a small cross appears on the pitch marking the position where the ball will fall... How can you find out the position where the ball will fall ahead of time?

[color=#323D4F]Any idea or explanation on how this could be done is very much appreciated icon_smile.gif

[color=#323D4F]thanks
You can isolate the code that does the simulation of how the ball moves and run it forward until it hits the ground. That's probably the best way to do it.
Advertisement

You can isolate the code that does the simulation of how the ball moves and run it forward until it hits the ground. That's probably the best way to do it.

That is probably the most computing time intensive way if you do the whole simulation.

The movement of the ball is really simulated through the integration of its position. Usually through a differential equation of second degree (velocity and acceleration). Instead of running the whole simulation you just have to compute to the time step when the Y coordinate becomes 0.
Student of Computer Science - Digital Media and Games

Check out my blog, where I document my learning process in game development:
http://nighttimedeve...nt.blogspot.de/

Always thankful for help.

[quote name='alvaro' timestamp='1342097376' post='4958380']
You can isolate the code that does the simulation of how the ball moves and run it forward until it hits the ground. That's probably the best way to do it.



That is probably the most computing time intensive way if you do the whole simulation.

The movement of the ball is really simulated through the integration of its position. Usually through a differential equation of second degree (velocity and acceleration). Instead of running the whole simulation you just have to compute to the time step when the Y coordinate becomes 0.
[/quote]

If you have an analytic solution to the differential equation, you can certainly use it. However, once you take effects like drag and spin into account, you are going to have to do it numerically. If you simply run the simulation you can be certain that the result will be correct. If this takes too long (I doubt it, since you are only simulating one object and you don't need to run collision detection or anything of that sort), you can increase the time step and trade accuracy for speed.

This topic is closed to new replies.

Advertisement