-
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.
-
What is the issue? I can’t figure out how to achieve this.
-
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)```