Adjusting kinematicbody2d's mass

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Uralkemal

Hello I made a car with kinematicbody2d. While 2 cars are going to same direction if one car hits other from behind it stops immediately. (the car which hits behind stops). Anyway I can tweak more collision options?

:bust_in_silhouette: Reply From: kidscancode

A KinematicBody2D does not have a “mass” - there are no physics properties in a kinematic body, just movement and collision.

If you want a particular collision response, you have to code it yourself. You could assign a mass and then on collision calculate a resulting force, applying it as an acceleration to the body. All this has to be calculated in your script.

Depending on how complex you want to get with it, it may be easier to use RigidBody2D and let the physics engine take care of things for you.

Thank you for your reply! Okay I convert it to RigidBody2D but now there is a new problem. I set_friction to 1(which is max). I still get on friction at all. I made a research and found out i have to set gravity. But problem is my game has top down view. Is there a way to apply friction without turning on gravity?

Uralkemal | 2019-10-23 09:18

The ‘friction’ property is about how the body moves when in contact with other bodies. If you’re top-down and talking about friction with the “ground”, you want to set the `linear_damp’.

kidscancode | 2019-10-23 14:21