Jump to content
• Advertisement

# Math / Programming Question

This topic is 3680 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

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!

#### Share this post

##### Share on other sites
Advertisement
Its considered rude to cross-post. Don't do it next time.

... and really??? All you need to do is subtract the position of the asteroid from the position of earth, presuming you want a direct vector and not a curved path.

#### Share this post

##### Share on other sites
Thanks for the reply..

Subtracting the vector was the first thing that I tried... but it didn't do what I thought it would. Maybe there is an issue with my movement controller. I will keep trying but yeah, I am very new to 3D vectors. Thanks for the reply and sorry for the cross post.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
A4L
13
5. 5
• Advertisement

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633767
• Total Posts
3013737
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!