Physics 1 student, making a physics based and I need a little math help

Click For Summary
SUMMARY

The discussion centers on implementing Newton's gravity equation, F = G(m1*m2)/(r^2), in a 2D physics-based game. The user is facing challenges with movement dynamics, specifically the wobbling of a planet due to improper handling of acceleration and speed. The suggestion is to resolve both velocities and accelerations into x and y components, adjusting for positive or negative acceleration based on position changes over time. This approach aims to stabilize the movement of the planet in the game.

PREREQUISITES
  • Understanding of Newton's gravity equation and its application in game physics
  • Basic knowledge of 2D coordinate systems and vector resolution
  • Familiarity with trigonometric functions, specifically sine and cosine
  • Experience with game development frameworks that support physics simulations
NEXT STEPS
  • Research how to implement vector resolution in game physics
  • Learn about integrating physics engines like Unity's Rigidbody or Box2D
  • Explore techniques for smoothing movement in physics simulations
  • Study the effects of mass and distance on gravitational forces in game mechanics
USEFUL FOR

Game developers, physics enthusiasts, and anyone interested in creating realistic movement dynamics in 2D games.

someoneYEAH!
Messages
1
Reaction score
0
Hooray for long titles...

Anyway, I wasn't quite sure where to post this, sorry if this is in the totally wrong forum.

As you may have gathered from the title, I am attempting to make a physics based game. The primary equation in this game is Newton's gravity equation.

F = G(m1*m2)/(r^2)

I mangled it to where it actually works with numbers thrown around in the game while not changing it too much, but here's my problem, my game is on a 2D plane, and I cannot figure out how to get my movement to work out right.

I fuse the x-axis and y-axis distances into one distance at the beginning, and, of course, to get what I want to move I have to split that value up using cos and sin. So I split it up after I find the acceleration from the force and then check the distances to see if the acceleration should be positive or negative. It ends up that in certain cases, the planet will sort of wobble back and forth as it moves.

it's easier to show: http://ian.janasnyder.com/phys.png

I think my problem is that I should be splitting up the speed rather than acceleration, but then how do I tell whether to add or subtract acceleration?

Any tips?
 
Last edited by a moderator:
Physics news on Phys.org
Not sure if this is any help, but from the hip, and assuming the "attractor" is much more massive than the "planet", I would put the attractor at the origin and resolve both velocities and acceleration into x and y components. If on successive time frames, the absolute value of the x or y position is becoming larger, then the acceleration is retarding, and vice versa.
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 10 ·
Replies
10
Views
4K
Replies
5
Views
2K
  • · Replies 76 ·
3
Replies
76
Views
9K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 12 ·
Replies
12
Views
3K
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K