Football game coursework, I need help writing a script.
6 views (last 30 days)
Show older comments
Im writing the script for a player who needs to move to wherever the ball is on the pitch which will change through out the game. I just need him to chase the ball and stay on the pitch and I don't really know where to start with it any help would be appreciated, thanks.
4 Comments
John D'Errico
on 5 Feb 2015
Were I a betting man, my bet would be that the reference to pitch suggests it is a different kind of football indicated here.
Accepted Answer
Star Strider
on 5 Feb 2015
The most sophisticated solution is likely a Kalman filter. However, I would start instead with a relatively simple Pursuit curve solution. This would likely be much easier to implement.
2 Comments
Star Strider
on 5 Feb 2015
My pleasure!
I doubt that an analytic solution would be appropriate, since the trajectory of the football is always changing. (If you have the Symbolic Math Toolbox, that might where to start, though, to give you some idea of how the differential equation solves the pursuit problem in a simple system. Use matlabFunction to create an anonymous function so you can see it outside of the Symbolic Math Toolbox, and so without all that Toolbox’s computational overhead.)
You likely need to explore the various ODE solvers to determine the best one for your simulation. I would start with ode45, and use the ‘Events’ structure to determine when the ball or player goes out-of-bounds. You will likely use ode15s, since it is much more robust in ‘stiff’ problems, and this could be one such.
It seems to me that this is quite complicated, although for a simple trajectory it might be easy. If it gets involved, you might consider searching out the solutions video game developers use, and how the various video game engines handle those problems. At least in your simulation, you likely don’t have to worry about the offsides rule!
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!