A-chassis System Help

Does anyone know how to stop A-chassis decreasing the speed when u have a collision? Its interrupting my crash system by giving me false speed figures.

I thought this is how physics work. what do you mean?

When I have a collision in my vehicle, it reduces the speed, yes this is what happens irl, but for my collision script i need to get the speed at the time of collision and its giving me false numbers. I was driving at around 30mph and it said i was going 20 or less.

You have to track the Previous speed of the vehicle so that when you collide you can use the Previous speed to know how fast it was going.

How can i go about doing that?

I’m not sure if I coded this exactly right, but this is something I would do

local PreviousLinearMagnitude = 0

game:GetService("RunService").Heartbeat:Connect(function()
	local CurrentLinearMagnitude = DriveSeat.AssemblyLinearVelocity.Magnitude
	local LinearAcceleration = (CurrentLinearMagnitude - PreviousLinearMagnitude)
	
	if LinearAcceleration>15 then -- If the velocity of the vehicle dropped by 15 or more then that is detected as a collision
		print("Collision detected! Last speed: "..PreviousLinearMagnitude)
	end
	
	PreviousLinearMagnitude = CurrentLinearMagnitude
end)

With A-chassis system, the speed is measured in MPH, and this is the line which calculates this

math.round(values.Velocity.Value.Magnitude * 280 / 1000 * 2.23693629)

I think the logic would be completely different from A-chassis.

That’s probably the speed for display which isn’t actually used. In code you should not use this because it would be inaccurate. You should stick to measuring in Studs since that is how Roblox physics are measured in.

The logic shouldn’t be too different or different at all.

1 Like

I’ve got it somewhat working, but i need to be able to detect what was hit for allow for damage, how can i achieve this? Part.Touched is too unreliable.

Something like this may work, there may be adjustments needed

local PreviousLinearMagnitude = 0

	game:GetService("RunService").Heartbeat:Connect(function()
		local CurrentLinearMagnitude = DriveSeat.AssemblyLinearVelocity.Magnitude
		local LinearAcceleration = (CurrentLinearMagnitude - PreviousLinearMagnitude)

		if LinearAcceleration>15 then -- If the velocity of the vehicle dropped by 15 or more then that is detected as a collision
			local Params = OverlapParams.new()
			Params.FilterDescendantsInstances = {YourVehicleModel}
			
			local Bounds = workspace:GetPartBoundsInBox(Hitbox.CFrame, Hitbox.Size, Params)
			for _,v in Bounds do
				if v.Anchored==true then
					print("Hit: "..v.Name)
				end
			end
			
			
			print("Collision detected! Last speed: "..PreviousLinearMagnitude)
		end

		PreviousLinearMagnitude = CurrentLinearMagnitude
	end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.