Question: Normalforce (in the universe)?

  • Context: Undergrad 
  • Thread starter Thread starter Xcrypt
  • Start date Start date
  • Tags Tags
    Universe
Click For Summary

Discussion Overview

The discussion revolves around the concept of normal force in the context of a 2D game development project involving a tank on different planets. Participants explore how to implement a force that prevents the tank from falling through the planet's surface during collisions, examining both theoretical and practical aspects of this force in a game physics context.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant describes their implementation of gravitational attraction between the tank and planets using Newton's law of universal gravitation.
  • Another participant suggests that the normal force is the force required to prevent the planet from moving and proposes checking for intersection between the tank's position and the planet's surface as a solution.
  • A different participant expresses curiosity about calculating the normal force and seeks further clarification on the concept.
  • One participant explains that the average force during a collision can be calculated using the change in momentum and the duration of the collision.
  • Another participant elaborates on the dynamics of collision, discussing impulses and how the tank's motion should be managed post-collision, including considerations for maintaining contact with the planet's surface.
  • Participants discuss the complexities of modeling the normal force, including the effects of other forces acting on the tank and the potential for energy dissipation during impacts.

Areas of Agreement / Disagreement

Participants present multiple competing views on how to calculate and implement the normal force, with no consensus reached on a single approach. The discussion remains unresolved regarding the best method for handling collisions and the normal force in the game.

Contextual Notes

Participants mention various assumptions, such as the tank's velocity and the nature of the collision, which may affect the calculations. The discussion also touches on the implications of using discrete time steps in the game engine.

Xcrypt
Messages
20
Reaction score
0
Hello, I am studying game development, I'm in my first year and have to make a 2D game in C++ for a project. I'm sorry if this is considered homework and thus posted it in the wrong board. Also my knowledge of physics is very basic so please excuse me for my amateurism. I tried to contact my teachers about this problem but they don't seem to understand it.

The game is a 2D shooter game in space, where you have control over a tank as player. In one level, there are different planets. The projectiles the tank shoot follow paths based on the addition of multiple 'planet-object' attraction force vectors. The tank itself also has to be attracted to the planets. I will show you some code of how I did this:

it is based on the formula: F=G*((m1*m2)/r^2)

Vector2D PlanetList::CalculateGravityVector(Point2D ObjectPosition, double ObjectMass, InputState* inputStatePtr)
{
//Calculate vector: the addition of all attraction force vectors of the object to a specific planet

double F,distance,angle;
Point2D PlanetPosition;
Vector2D vdistance, tempGravityVector;
Vector2D GravityVector(0,0);
Vector2D AngleZero(1,0);

for (int x=0 ; x<MAXNRPLANETS ; ++x)
{
if (m_PlanetPtrArr[x]!=0)
{
//First: Calculate the attraction force between the object and the [x]'nd planet in the list
//F = G * ((m1*m2)/r^2)
PlanetPosition = m_PlanetPtrArr[x]->GetPosition();
vdistance = PlanetPosition-ObjectPosition;
distance = vdistance.Length();
F = m_GravitationConstant*((ObjectMass*m_PlanetPtrArr[x]->GetMass())/(distance*distance));

//Put the Force in a Vector2D
//To achieve that, calculate the angle first

angle = vdistance.AngleWith(AngleZero);
tempGravityVector.x = cos(angle)*F;
tempGravityVector.y = sin(angle)*F;

//Add this vector to the Vector2D we need.
GravityVector+=tempGravityVector;
}
}


return GravityVector;
}

This function will be implemented in a Tick() function, this means that in the program, the vector will be calculated for every tick (usually 1/60 s).

I think I have this part right. But I also want to implement a force (I think it is called normalforce), that makes it so when the tank and the planet collide, that makes the tank unable to fall through the crust of the planet.

My question is: what kind of force is this, and how do I calculate this?

(I made a quick sketch of the problem in paint, check attachments.)

At first I thought this was Fn = -Fz, but then I realized this wouldn't work, because suppose the tank is moving at 200pixels/second, with an acceleration of only 2px/s^2, and a mass of 500 units, only the acceleration and the mass play a role, meaning that the velocity of the tank would not increase anymore, but still stay at 200px/s when the tank collides with the crust of a planet.

Help is much appreciated.
 

Attachments

  • Gravity Problem.jpg
    Gravity Problem.jpg
    20.9 KB · Views: 542
Last edited:
Space news on Phys.org
The normal force is whatever force is required so that the planet doesn't move. The best way to implement it is simply as a constraint on the motion. I.e. figure out if the line from the tank's old position to the tank's new position intersects the surface of the planet, if so then the tanks new position is the intersection and the tank's new velocity is the planet's velocity.
 
That is indeed a good solution. However I am still kind of curious how to calculate this force, I may be an amateur in physics, I actually am quite interested in them. Any ideas?
 
This is a collision, so the average force on an object in a collision depends on two things: the change in the object's momentum (Δp) and the duration of the collision (Δt).

F=Δp/Δt

In your case if the planet is at rest then Δp is equal and opposite to p and Δt is your video game's time step.
 
The problem here is that there will first be a collision and force of collision and then the tank will presumably ride along with the planet or at least maintain motion only along the surface.

Since you are using ticks instead of continuous time what you really are working with is impulses (force time tick length) which has units of momentum. The force of impact will vary over the time the impact takes place but you can figure the total impulse is that which is sufficient to stop the tank's motion relative to the planet m(Vplanet - Vtank) or if you want to have it coast along the planetary surface, the impulse will be just the normal component.

You can also allow it to bounce elastically by reversing the normal momentum.

This impact impulse would occur at the first tick where the tank and planet intersect. You would then, while they are in contact, maintain the normal force equal and opposite to the normal component of all other forces acting on the tank.

If you're standing on the ground you may have many forces acting upon you, Earth's gravity, the pull of the moon, some guy giving you a knoogie etc. The ground doesn't just oppose gravity but the net force trying to push you into it.

Ultimately it is acting as a very stiff spring, pushing back on you in proportion to the small amount you sink into it. That amount will be determined by other forces acting on you and by your inertia if you're being slammed into the ground. If you try to model it this way though you will end up with bouncing objects. There is a dissipation of energy occurring as well. You leave an indention in the Earth as you move away so it doesn't push back returning the energy required to depress it. (and given enough force it leaves you deformed as well.) To model that non-bouncing repulsion simply eliminate the normal velocity as suggested, or implement the one-time impact force or impulse I suggested.
 
Thanks, very clarifying :)
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
15K
Replies
2
Views
3K
  • · Replies 24 ·
Replies
24
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K