View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Figuring out normal force.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

8 replies to this topic

### #1boogyman19946  Members

Posted 25 January 2014 - 03:57 PM

Hello everyone!

I have a question that pertains to figuring out normal force. I seem to have a predicament that involves collision detection.

At the start I first sum all the forces acting on the object at hand. All external forces come from input or collisions that were maybe applied last cycle. Then all the internal forces: friction, gravity, and normal force. Gravity I can figure out, but figure friction requires me to know the normal but for that I have to know if I'm standing on a platform or not. My question is, is there some elegant way to solve this? For example, is it plausible to just omit the normal force on the first cycle, check collisions and apply the normal force on the next? Or should I make a deliberate check if player is standing on a platform?

### #2dejaime  Members

Posted 26 January 2014 - 01:37 AM

It looks like you are making a step into the Continuous Collision Detection concept.

The idea is simple. You should first detect the collision between the two bodies, platform and player. When this type of collision is made, you mark it them as colliding, thus activating your continuous contact routines, which should apply the normal force. While they are marked as colliding, you should apply the normal, and keep in watch for a break of this contact, that could be caused by several things:

The player jumps

The player goes beyond the platform border

A new force is applied (a bomb, a bullet, a backflip kick from a rhino...)

Any force change (weakening gravity, variable magnetic force)

This is a simplified version of the theory, also notice that it is my own interpretation, but it is quite a complex algorithm and I am searching the Box2D code to understand its implementation myself; so I can't help you further, but if you like to read code, here is a link that can.

You could use a simpler but specialized version. It would probably perform even better.

### #3Buckeye  GDNet+

Posted 26 January 2014 - 10:45 AM

From your description, it sounds like the platform is not a collision object. If you make the platform a collision object, a collision will result (when appropriate) between the player and the platform, and provide the point of contact and the contact normal. (Many collision engines provide for a planar collision object with a normal, an extent, friction factors, etc.)

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

### #4Mr. Lawliet  Members

Posted 26 January 2014 - 01:22 PM

The normal force minus gravity equals 0 if you are standing on a platform.

N - G = 0
N = G


"Don't gain the world and lose your soul. Wisdom is better than silver or gold." - Bob Marley

### #5boogyman19946  Members

Posted 26 January 2014 - 07:57 PM

It looks like you are making a step into the Continuous Collision Detection concept.

The idea is simple. You should first detect the collision between the two bodies, platform and player. When this type of collision is made, you mark it them as colliding, thus activating your continuous contact routines, which should apply the normal force. While they are marked as colliding, you should apply the normal, and keep in watch for a break of this contact, that could be caused by several things:

The player jumps

The player goes beyond the platform border

A new force is applied (a bomb, a bullet, a backflip kick from a rhino...)

Any force change (weakening gravity, variable magnetic force)

This is a simplified version of the theory, also notice that it is my own interpretation, but it is quite a complex algorithm and I am searching the Box2D code to understand its implementation myself; so I can't help you further, but if you like to read code, here is a link that can.

You could use a simpler but specialized version. It would probably perform even better.

This seems to be pretty much what I was looking for. I wasn't sure what to look up but I'll have a look at this when I have time and get back to you on that.

From your description, it sounds like the platform is not a collision object. If you make the platform a collision object, a collision will result (when appropriate) between the player and the platform, and provide the point of contact and the contact normal. (Many collision engines provide for a planar collision object with a normal, an extent, friction factors, etc.)

The platform is a collision object. The entire world in my game is actually made out of discrete objects. My question should have been "how do I know if I'm standing on a platform if I haven't detected collisions yet on this cycle." My physics simulator does things in the following order: sum forces, get acceleration, integrate acceleration and velocity, and with the resulting disposition, check collisions and respond. The problem with this is that I won't know if I'm standing on a platform until I check collisions, but I need to know that when I'm summing forces because of the normal force.

The normal force minus gravity equals 0 if you are standing on a platform.

N - G = 0
N = G


The question isn't that simple I'm afraid. And I don't want to be a party pooper, but on an inclined surface, N != G.

### #6dejaime  Members

Posted 26 January 2014 - 08:23 PM

The normal force minus gravity equals 0 if you are standing on a platform.

N - G = 0
N = G


It is not that simple, I suppose...

As boogyman pointed out, on any inclined surfaces, they'd have different values. The normal would also be in a different direction.

Important to notice, the normal isn't a reaction to gravity, but to everything that forces something against a surface. So, if you are on a rising platform, for example, it could have a normal that is higher than the sole effect of gravity.

As a side note, gravity is actually acceleration while normal is a force, I would try to avoid this kind of misleading comparison...

Edited by dejaime, 26 January 2014 - 08:27 PM.

### #7boogyman19946  Members

Posted 26 January 2014 - 09:10 PM

N - G = 0
N = G


Oops, seems like I've been lazy with my terminology. I meant to say "force of gravity," or "weight" if you will.

EDIT: Seriously, I give up on quoting mechanism. I fail so hard at it XD

Edited by boogyman19946, 26 January 2014 - 09:11 PM.

### #8Mr. Lawliet  Members

Posted 27 January 2014 - 03:44 AM

On inclined surfaces the normal force will be equal with the sine or cosine of the inclined surface angle * gravity . Am I right?

Edited by Bratie Fanut, 27 January 2014 - 03:45 AM.

"Don't gain the world and lose your soul. Wisdom is better than silver or gold." - Bob Marley

### #9boogyman19946  Members

Posted 27 January 2014 - 11:52 AM

On inclined surfaces the normal force will be equal with the sine or cosine of the inclined surface angle * gravity . Am I right?

I always remember it as the negative projection of the gravity force onto the normal vector of the surface where the object is rested.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.