{"author_name":"LunarCrisis","cat":"LD #11 - Minimalist - 2008","comments":[{"author_name":"DrPetter","time":"April 19, 2008 2:19 pm","epoch":1208632740,"text":"Looks great&#8230; in all its gritty mathyness. I might inspect it in the morning, but that hour of equation-wielding on irc bled me dry for the day so I will just take your word for it until then \ud83d\ude09","spam":"N"}],"epoch":1208628840,"likes":1,"metadata":{"p_key":"75207","p_author":"LunarCrisis","p_authorkey":"176","p_urlkey":"111039","p_title":"Re: Distractions Deluxe","p_cat":"LD #11 - Minimalist - 2008","p_event":"LD11","p_time":"1208628840","p_likes":"1","p_comments":"1","p_status":"UPD5","us_key":"176","us_name":"LunarCrisis","us_username":"lunarcrisis","event_start":"1208476800","event_key":"87","event_name":"LD11"},"text":"<p>My solution:<\/p>\n <p>So the problem is to \u001cfigure out the direction a player (moving in 3-d) has to shoot to hit an enemy (also moving in 3-d) given their positions, velocities, and the speed of the bullet.<\/p>\n <p>The approach I used was to solve the equation<\/p>\n <blockquote><p>time it takes the enemy to reach a position = time it takes the bullet to reach the position<\/p><\/blockquote>\n <p>for the time.<\/p>\n <p>First, redefi\u001cne the vectors so that they are all relative to the player. This<br \/>\n leaves you with only bullet speed, enemy velocity, and enemy position. The<br \/>\n points in question are the points along the enemy&#8217;s trajectory, so express the<br \/>\n above equation in terms of t:<\/p>\n <p><a href=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2008\/04\/b1.png\" title=\"b1.png\"><img src=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2008\/04\/b1.png\" alt=\"b1.png\" \/><\/a><\/p>\n <p>This can be solved with the quadratic equation:<\/p>\n <p><a href=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2008\/04\/b21.png\" title=\"b21.png\"><img src=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2008\/04\/b21.png\" alt=\"b21.png\" \/><\/a><\/p>\n <p>Note that there may be zero, one, or two solutions. Negative solutions reflect hits in the past. If there are no positive solutions it is not possible for the player to hit the enemy.<\/p>\n <p>Once you have t, it is simple to calculate the position.<\/p>\n <p>Edit: forgot the exponent on the bottom of the final answer.<\/p>\n \n <p>Tags: <a href=\"http:\/\/ludumdare.com\/compo\/tag\/aiming\/\" rel=\"tag\">aiming<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/algorithms\/\" rel=\"tag\">algorithms<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/bullets\/\" rel=\"tag\">bullets<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/distractions\/\" rel=\"tag\">distractions<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/math\/\" rel=\"tag\">math<\/a><\/p>","time":"April 19th, 2008 1:14 pm","title":"Re: Distractions Deluxe"}