I’ve been trying to get accurate results of the force when the part hits an object.
Using this code doesn’t give accurate results of force:
local partVelocity = part.AssemblyLinearVelocity
local hitVelocity = hit.AssemblyLinearVelocity
local force = (partVelocity - hitVelocity).Magnitude
It would return the speed of the part but when the part is sliding on the ground, it would return high numbers.
To prevent this, I tried using the kinetic energy force but I’m not very good at this so this is what I got:
local part = script.Parent
local function OnTouched(hit)
local partVelocity = part.AssemblyLinearVelocity
local hitVelocity = hit.AssemblyLinearVelocity
local relativeVelocity = (partVelocity - hitVelocity)
local partMass = part.AssemblyMass
local force = 1/2 * partMass * relativeVelocity * relativeVelocity
local normalForce = partMass * workspace.Gravity * math.cos(0)
local kineticFriction = math.cos(force.Magnitude) * normalForce
print(kineticFriction)
end
script.Parent.Touched:Connect(OnTouched)
Not sure if I’m doing this right. Can someone help me?
Friction = F * μ.
The equation gives the maximum friction so you’ll probably need to clamp it so it doesn’t send your part flying backwards. μ is a constant that is dependent on the material. F is the reaction force (the force applied to a part to stop it from phasing through a surface) and will always act against the direction of movement.
On a flat surface F is simply its mass * gravity (F = ma), also known as the weight.
On a sloped surface is a little bit more complicated. You’ll need to multiply the weight by cos(theta) to get the component that is perpendicular to the surface (the reaction force!). theta is the angle between the floor and the normal.
Not in highschool so this is a bit complicated. I’ve never learned about theta.
Saw this formula but I don’t know how to get the adjacency: Cos(θ) = adjacency/hypotenuse