How to detect if a car hits an object going fast and eject them from car

  1. What do you want to achieve? I want to detect if a car hits an object fast and if they did eject them from the car.

  2. What is the issue? I can’t figure out how to achieve this.

  3. What solutions have you tried so far? Tried using AssemblyLinearVelocity, it would eject all the time

	if carseat then
	local currentVelocityMagnitude = carseat.AssemblyLinearVelocity.Magnitude
	local currentTime = tick()

	local timeDelta = currentTime - lastUpdateTime
	local acceleration = (currentVelocityMagnitude - lastVelocityMagnitude) / timeDelta

	local accelerationThreshold = 5 
		print(acceleration," acc")
		print(accelerationThreshold, " thresh")
		
	if acceleration > accelerationThreshold then
			print("ejected")
			--ejectPlayer(player, carSeat)
		
	end

	lastVelocityMagnitude = currentVelocityMagnitude
		lastUpdateTime = currentTime
		end
end)```
1 Like

You could have a hitbox at the front of the car (or wherever you want it) and use the .Touched event to check when its touched. Then i would probably make sure the object it touched isn’t part of the car, and finally check the car’s AssemblyLinearVelocity and make sure its going over a certain speedㅤ:P