Skip to main content
GameDev.net gamedev.net
🔒 Locked

Math / Programming Question

Started by timbo317 Nov 21, 2008 at 12:16 AM 2 replies 600+ views
Original Post
timbo317
timbo317
Hey guys, I have (what should be) a very easy question. I am new to game design, but have been programming in JAVA for about 6 years now. I am createing a JAVA 3D asteroids game, using JME. I have a sphere set in space which represents Earth. My idea is to have "asteroids" created in various locations (3fVector), and then have the asteroids move toward earth. The player has to shoot the asteroids before they hit Earth. Simple enough, but I am having problems with the math involved in determining the "direction" these asteroids need to move in order to eventually hit earth. I am throwing spheres out in space in random places with the method asteroid.setLocalTranslation(x,x,x); So, how would I then determine the relative position to move to eventually collide with earth? Hope that makes sense, I am sure there is just some mathematic formula where you can take the 3fVector location of the asteroid, and the 3fVector location of the earth, and come up with a directional vector that the asteroid needs to be moved, but I am very lost on what that formula might be. Thanks guys!
gekko
gekko
Subtract the two vectors. In other words, to construct a vector PQ from point P to point Q, take Q - P.
-- gekko
timbo317
timbo317
Thanks man

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.