#### Archived

This topic is now archived and is closed to further replies.

# How to represent forces and such

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

## Recommended Posts

I have absolutely no clue how to represent real forces the ''real way'' in a computer program. In the loop I''ve got right now, every object moves when the loop gets to it, and it tries to collide with where ever the other objects are currently at (first come, first serve basis). That''s the first problem. The second problem is trying to get forces to persist over multiple frames. For example, I''ve got a playable demo where you run around quake3 maps trying to shoot bert. When you actually shoot a bullet and hit bert''s arm I''m trying to get it so that his arm will rotate backwards. Obviously the force is basically applied instantaneously, but the effect needs to persist over multiple frames until the forward force of his arm can make his arm swing forward back to the normal position. I''m looking into scene graphs for representing objects but I''m not really sure how to go about this the real way.

##### Share on other sites
not sure I understand what you are looking for, but I''ll give it a try.

a bullet hit produces an impulse, and is not a persistant force. the impulse will generate a linear and angular momentum on the object (the object will start to rotate), and given no friction is applied, the object will keep on rotating until you produce another impulse that cancels out the angular velocity (ever shoot the other arm, or shoot the same arm from the other side). That can be handled by basic rigid body dynamics.

Collison impulses generate a change in momentum instantaneously (as soon as a collision is found). force fields, like gravity, well, you can keep track of them inside each bodies.

##### Share on other sites
yeah, that''s exactly what I''m doing. I guess I just don''t know the right way to actually do that in code. Can you show me some psuedo code of how and when your physics is handled in your code?

##### Share on other sites
For things like these there''s the "logic loop" of your game. Aiming for independent speed on different pcs is generally a good idea, so you''ll have to separate the graphics stuff from the logics. And the physics do absolutely fit into the logic part. As for me, I have my update() method for each Actor / Object, and this is where the collision detection will be handled, the A.I. (if any), the physics, ...

Indeterminatus

--si tacuisses, philosophus mansisses--

##### Share on other sites
3D rigid body example

Home

1. 1
Rutin
19
2. 2
3. 3
JoeJ
15
4. 4
5. 5

• 18
• 19
• 10
• 13
• 17
• ### Forum Statistics

• Total Topics
631694
• Total Posts
3001751
×