# How do I make ground friction in Physics (top-down)

From the Asset Store
25 high quality isometric ground blocks + sprite sheet
• I am moving the object ( a tank ) with physics forces, for it to work well with Immovable walls etc.

The only trouble it seems is no Dentisty-Force ratio provides what I need -- the tank to stop when force is not applied any longer. It always floats like its on ice.

Please not that setting velocity to 0 when key is released does not work since I want it to collide with walls and other vehicles.

I am very new to Physics, so excuse me If I asked something dumb. There seem to be very few tutorials on Physics.

• No worries. Most of the things you need to know about the way physics simulations work aren't actually taught until you take a course in numerical physics or modeling at the university level, so you aren't alone!

Here are the basics:

Friction: This sounds like it should be what you are looking for, but it is not. In computer games, "friction" is a retarding force between 2 physics objects, but since this is a top-down game, the "ground" is actually not a physics object. Therefore friction will not have any effect in a top-down 2D game.

Linear damping: This is probably what you want***. Linear damping applies a force backward that is proportional to speed. The slower the object is moving, the smaller the retarding force. Note that this technically means the speed will never reach zero, but it will quickly approach zero such that you can apply a check to see if speed < 1, set speed = 0.

Angular damping: This works just like linear damping, but for rotation.

***Note that "linear damping" is actually a better simulation of air drag than of skidding along the ground. Ground friction is best modeled as a constant force, but you will need to do a number of additional checks to make it completely accurate, and I'm not sure it is worth the effort and extra events for a game. To see the difference between friction and air drag in action, go to https://www.simbucket.com/simulation/rocket-sled/.

• Well it is a 2D engine. You want it to work as a 3D engine.

When you move a Sprite with an X and Y vector, then whats under that sprite is depth, or Z.

Density, Friction, and Plasticity is about interaction with objects in the XY plane, not Z.

But. You can do this. You need to detect what it is overlapping. If they are different sprites, give them an instance variable 'Friction'. How more the value in it, how more the slow down. Value should range from 1 to 5 or so.

If they are different sprites, you need a Family to group them in 1 'is overlapping' event.

If they are instances of a sprite, you best write the value of that instance variable 'on start up' depending on the animation frame.

If it is a tilemap, it will be easier to use a lookup table(in the form of an array) with X-index = Tile index, and the slow down value on the Y-index (x,1).

For sprites.

(Tank) is overlapping (ground)

_____ (Tank) Set linear damping ... to Sprite.Friction

For a tilemap.

Pick the Tank somehow

_____ (Tank) Set linear damping ... to ... Array.at( (Tilemap.TileAt(Tank.X, Tank.y)) , 1) .. assuming that X=index = tile index, and y=1 is that slow down value. The array is a lookup table, you use it to translate a value (stored on X) to a paired up value (stored on Y).

• No worries. Most of the things you need to know about the way physics simulations work aren't actually taught until you take a course in numerical physics or modeling at the university level, so you aren't alone!

Here are the basics:

Friction: This sounds like it should be what you are looking for, but it is not. In computer games, "friction" is a retarding force between 2 physics objects, but since this is a top-down game, the "ground" is actually not a physics object. Therefore friction will not have any effect in a top-down 2D game.

Linear damping: This is probably what you want***. Linear damping applies a force backward that is proportional to speed. The slower the object is moving, the smaller the retarding force. Note that this technically means the speed will never reach zero, but it will quickly approach zero such that you can apply a check to see if speed < 1, set speed = 0.

Angular damping: This works just like linear damping, but for rotation.

***Note that "linear damping" is actually a better simulation of air drag than of skidding along the ground. Ground friction is best modeled as a constant force, but you will need to do a number of additional checks to make it completely accurate, and I'm not sure it is worth the effort and extra events for a game. To see the difference between friction and air drag in action, go to https://www.simbucket.com/simulation/rocket-sled/.

Now comes a trouble that even on 1 (maximum) some movement still noticeable after the force stopped being applied. How do I make it stop dead when the key W, for example, is released?

• Well it is a 2D engine. You want it to work as a 3D engine.

When you move a Sprite with an X and Y vector, then whats under that sprite is depth, or Z.

Density, Friction, and Plasticity is about interaction with objects in the XY plane, not Z.

But. You can do this. You need to detect what it is overlapping. If they are different sprites, give them an instance variable 'Friction'. How more the value in it, how more the slow down. Value should range from 1 to 5 or so.

If they are different sprites, you need a Family to group them in 1 'is overlapping' event.

If they are instances of a sprite, you best write the value of that instance variable 'on start up' depending on the animation frame.

If it is a tilemap, it will be easier to use a lookup table(in the form of an array) with X-index = Tile index, and the slow down value on the Y-index (x,1).

For sprites.

(Tank) is overlapping (ground)

_____ (Tank) Set linear damping ... to Sprite.Friction

For a tilemap.

Pick the Tank somehow

_____ (Tank) Set linear damping ... to ... Array.at( (Tilemap.TileAt(Tank.X, Tank.y)) , 1) .. assuming that X=index = tile index, and y=1 is that slow down value. The array is a lookup table, you use it to translate a value (stored on X) to a paired up value (stored on Y).

An excellent scheme, will definitely use when work will begin on different ground types.

• Ah . You can actually raise the linear damping coefficient past 1. I'm not sure why they listed a maximum value - in real life it can be any quantity greater than zero.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Ah . You can actually raise the linear damping coefficient past 1. I'm not sure why they listed a maximum value - in real life it can be any quantity greater than zero.

Well thats interesting

Thanks

• There are a lot of properties that are listed as a range between 0 an 1, but work perfect above 1.

See them as a scaling factor.

0 means no effect.

1 means the full effect.

2 means double the full effect ... and so on.

• 8 posts