#how to implement friction on an environment object

1 messages · Page 1 of 1 (latest)

buoyant brook
#

I'm making a physics engine and I'm wondering how I would do this

proven arch
proven arch
buoyant brook
#

I didn't find it unfortunately

sterile hazel
#

You need some way to detect if an object or a player is touching the ground it should get easier from there

brazen grotto
# buoyant brook I'm making a physics engine and I'm wondering how I would do this

You can create friction using the “Velocity Set” chip.

  • Whenever the physics object is in contact with a surface, remove velocity from the object that is perpendicular to the surface’s normal. Note that 9.81 m/s velocity is added in the downwards direction every second.
  • Perpendicular Velocity = (Get Velocity(Physics Object) - Vector3 Scale(Vector = Surface Normal, Scalar = Vector3 Dot(Get Velocity(Physics Object), Surface Normal))).
  • Parallel Velocity = Vector3 Scale(Vector = Surface Normal, Scalar = Vector3 Dot(Get Velocity(Physics Object), Surface Normal))
  • Velocity Set(Parallel Velocity + If Value(Condition = Greater Than(Vector3 Get Magnitude(Perpendicular Velocity), Kinetic Friction * Vector3 Dot(Get Velocity(Physics Object), Vector3 Scale(Vector = Surface Normal, Scalar = -1))), Then = Vector3 Scale(Vector = Vector3 Normalize(Perpendicular Velocity), Scalar = Vector3 Get Magnitude(Perpendicular Velocity) - Kinetic Friction * Vector3 Dot(Get Velocity(Physics Object), Vector3 Scale(Vector = Surface Normal, Scalar = -1))), Else = Vector3 Create(0, 0, 0)))
brazen grotto
#

My apologies, I forgot the +9.81 velocity per second.

#

I will update it later.

lime night
brazen grotto
# lime night velocity set doesnt work on environmental objects
  • Create a Vector3 variable “Object Velocity”.
  • Using “Update 30Hz”, set the position of the Physics Object to (Get Position(Physics Object) + Vector3 Scale(Vector = Object Velocity, Scalar = Delta Time)).
  • Using the same Update 30Hz, detect if the object is in contact with another object or surface. If it is, set the value of the Object Velocity variable to its Parallel Velocity + its Perpendicular Velocity * 0 to allow for friction, or its Parallel Velocity + its Perpendicular Velocity * [number less than 0] for bounce.
  • Using the same Update 30Hz, set Object Velocity to Vector3 Create(Vector3 Split(Object Velocity)[X], Vector3 Split(Object Velocity)[Y] - 9.81 * Delta Time, Vector3 Split(Object Velocity)[Z]).
  • Continue with the friction calculations.
brazen grotto
buoyant brook
#

Thank you @brazen grotto

brazen grotto
rugged thistle
#

yep, all he says is correct

If you want competely 100% realistic friction, you can use the formula F=mu x R where F is the frictional force, mu is the coefficient of friction, and R is the reaction force.
mu is a random arbitararu number for how much friction you want, it is a property of the material, so like carpet will have high mu, and metal will have low mu.

And R is the reaction force which can be calculated as the weight acting on the ground by the object, you can use the formula mass x gravity for this, or if its being pushed down it is mass x (gravity+downward force).

remember the friction will counteract the force of motion,

If it is on a slope you need to multiply by the cos of the angle of the slope and subtract by force of motion.
@buoyant brook

brazen grotto
#

Also, you do not need to have the gravity as (0, -9.81 * Delta Time, 0). Since you are using a custom velocity, you can have gravity that goes in any direction and is any magnitude (positive or negative, lesser or greater). @buoyant brook If you do end up creating this system, please feel free to send photos and/or videos of your results!

brazen grotto
heavy osprey
#

😭

brazen grotto