1

I'm working on making a simple-ish physics engine for my game, but I'm not sure how to do the math on part of it.

How I currently have my engine setup is as follows:

Every object affected by physics has a "velocity" which consists of it's angle and force.

Each object has an "push" function that takes a new velocity and affects the current velocity with it.

The angle of velocity is global. So moving towards the right of the screen will always have an angle of 90. For example, if an object's velocity has a force of 10 and an angle of 90 and I adjust said velocity by an angle of 180 with a force of 10 it'll get a new velocity. This velocity will have a force of 0, so it's angle is irrelevant. Or if I take that earlier velocity with an angle of 90 and a force of 10 and adjust it by a velocity with an angle of 180 and a force of 5, the resulting velocity will have the angle of 90 but the force of 10.

I'd provide more examples and test cases, but I don't know how to figure out the velocity of an object moving with a force of 13 and an angle of 32 when it's pushed by a velocity of 5 at an angle of 193.

TLDR;

I have objects with angular momentum. I want to be able to "push" them with a given force and angle and have them adjust accordingly(taking their current force and angle into account).

Legacyblade
  • 335
  • 1
  • 5
  • 18
  • i think you're getting your physics terms mixed up. once you say the arguments are new angle and velocity (which is not a force), then in your example you say adjust by pushing with a force of 8... – im so confused Dec 06 '13 at 21:36
  • Consider using an off-the-shelf physics engine rather than implementing this all yourself. See http://stackoverflow.com/questions/98628/2d-game-physics?lq=1. If you do really want to do it yourself, check out http://gafferongames.com/game-physics/ – Kristopher Johnson Dec 06 '13 at 21:37
  • 1
    If your objects don't have angular momentum, this is pretty simple. Just convert the velocity and impulse to vectors, add them, then convert them back to angle+magnitude. If the objects DO have angular momentum, this is the best thing you can read: http://chrishecker.com/Rigid_body_dynamics – Taylor Brandstetter Dec 06 '13 at 21:45
  • @TaylorBrandstetter I clarified what I was asking. My objects do have angular momentum. They're in a 2D plane and I want to be able to "push" an object and have it adjust course accordingly. I already know how to calculate a moving object's location each frame based on it's angle and force, I just don't know how to calculate said angle and force. I'll read that article you linked me to though :D Thanks for it. – Legacyblade Dec 06 '13 at 21:51
  • 1
    Are you sure you understand what angular momentum is? If your objects only have an angle and speed, they don't have angular momentum. Angular momentum would be if your objects can also spin while moving in a direction (think the asteroids in Asteroids). In which case, to do realistic physics, the objects also need a mass, a center of mass, and a moment of inertia, and each collision needs a point of contact and a normal vector. I wouldn't say it's "simple-ish". Also I think you're using the term "force" in place of "velocity" and "impulse". – Taylor Brandstetter Dec 06 '13 at 22:08

0 Answers0