Is it possible to make wheels react with its environment?

The car model I am using is just the modified racing template car system. Nothing has been changed in a big way just some ai stuff and other unimportant information.

I was wondering if you would be able to have the cars react differently with different terrain so some cars would find it difficult on dirt others track like in Forza or NFS.

I think this is the segment I would have to mess with right? I am not too well rounded on its workings.

--[[

Controller module script

]]

local function updateWheelFriction()
	for _, wheelPart in wheelParts do
		-- Find the difference between the wheel's actual linear speed and the speed it should be moving
		-- based on its current angular velocity.
		local speed = wheelPart.AssemblyLinearVelocity.Magnitude
		local angularVelocity = wheelPart.AssemblyAngularVelocity
		local targetSpeed = wheelRadius * angularVelocity.Magnitude
		local speedDiff = math.abs(speed - targetSpeed)

		local isKineticFriction = speedDiff > wheelParameters.slipThreshold
		local friction = if isKineticFriction then wheelParameters.kineticFriction else wheelParameters.staticFriction
		wheelPart.CustomPhysicalProperties =
			PhysicalProperties.new(wheelParameters.density, friction, wheelParameters.elasticity)
	end
end
1 Like

you can use raycasting

I need something that wont be a strain on the server or client. I do validate client and server data so I would have to do the ray on the server which could strain performance if upscaled.