Tag Info

Hot answers tagged

5

The bug is in the fall function. We have delta: a vector from the well to the ship force: the magnitude of the gravity between these two bodies. |force| is G * m1 * m2 / r^2 but |delta| is already r! so you are actually accelerating too fast. You need to divide by r again (basically normalizing the delta vector) before calling accelerate. ...


5

Intuition Here's one way: Let's rotate your diagram. Now the rocket is a cannonball! Physics It has a fixed acceleration "downwards" i.e. perpendicular to the vector from its firing location to its target. I drew it above as a dashed green line. Let's call that the reference horizon. (Note that this reference horizon is constant! The rocket was fired ...


3

It looks like the problem is that the missile is simply pointing itself at the target without regard for it's current velocity. Assign your missile a maximum angle by which the thrust can deviate from the line of motion. At each guidance iteration you calculate it's velocity perpendicular to the target. Figure out how much it must tip it's engine in order ...


3

It may not be the elegant solution you are after, but I've found that if I slow the missile, if it's going to miss, as it approaches the target, it effectively tracks and turns quicker and can hit the target. You could increase the turn rate of the missile as it gets closer, rather than reducing the speed, but this might give players a 'wow I'm sure that was ...


3

What you're looking for is an ArcBall Camera. I've got a full snippet over here http://roy-t.nl/index.php/2010/02/21/xna-simple-arcballcamera/ but just to explain the general idea: You set a look-at point in space which you want to orbit. Then you create a vector from that point by rotate around it using the Pitch Yaw and Roll. You then lengthen the vector ...


2

Note that even with the math bug(s) fixed, you're using Euler integration (i.e. velocity += delta and presumably position += velocity), so you're probably going to get some odd effects like rotation of the orbital ellipse over time, and perhaps the ellipse getting larger/smaller since Euler integration isn't guaranteed to conserve energy. You might want to ...


2

By the look of things you should be able to apply this script to your moon and simply point to the planetary object you want it to orbit. However given the fact that your planet is moving, it looks like your moons will probably be playing catch up to the planets orbiting the sun. You should be able to fix this with a simple hierarchy change. - Sun ...


2

I would suggest creating an arc-ball camera. This is a camera that can orbit around the point-of-interest and change its distance from the point-of-interest (basically zooming in and out). By simpling changing the location of the point-of-interest you get panning for free ;). Have a look at this code snippet: ...


1

If the players will never know the difference, then don't worry about mass or radius. For the oribiting planet store - the distance to the center planet (radius of rotation) - current position in degrees - orbit-speed (degrees per game tick) For each game tick - change the position by adding the speed - calculate the new position (using Cos and Sin) ...


1

If players have no effect over the orbit (such as moving planets) then the best option would simply be to define paths for the planet to travel along (using bezier curves etc). It's stable and simple. You would never be able to affect the movement in game (unless you went to the trouble of altering the defined path) and may open up unrealistic possibilities ...


1

I'd construct a line from the centre of the planet to the ship, and also calculate a point which is the ship's position + ship's velocity. From there you can use a standard test to find out which side of the line the point is on, which tells you if it should orbit clockwise or anticlockwise.


1

That's not so bad if you know the position of A and B at all times. Example: A is at the origin. B is traveling around the origin at a distance of 1. (ie, it's orbit is the unit circle) Let Y be the object leaving A. Let the speed of B be such that every second B crosses an axis. So the period of B is 4 seconds. Therefore the position of B at any given ...



Only top voted, non community-wiki answers of a minimum length are eligible