I’m tryna allow light poles to fall down when they are hit, however it’s not consistent. Sometimes my car will come to a complete stop, before moving through the pole (pole never falls over)
The car should not be stopped by a light pole. Ideally once hit, the part should be drive through able and fall over. Problem with setting the collision group instantly is the pole just never falls over.
function StreetLightDestructibleComponent:Start()
self.Trove:Connect(self.Instance.PrimaryPart.Touched, function(hit)
if not CollectionService:HasTag(hit.Parent, "Vehicle") then
return -- Not a vehicle, do nothing
end
if self.KnockedOver then
return
end
self.KnockedOver = true
Library:Weld(self.Instance, self.Instance.PrimaryPart) -- Weld all the parts
-- Unanchor the model (so it falls over)
for _, part in self.Instance:GetDescendants() do
if not part:IsA("BasePart") then
continue
end
part.Anchored = false
end
-- self.Instance.PrimaryPart:ApplyImpulse(hit.AssemblyLinearVelocity * 1000)
-- Wait a split second before disallowing collisions with the vehicle (gives model time to fall over)
task.delay(0.5, function()
for _, part in self.Instance:GetDescendants() do
if not part:IsA("BasePart") then
continue
end
PhysicsService:SetPartCollisionGroup(part, "Destructible")
end
end)
task.delay(Constants.DESTRUCTIBLE_RESPAWN_TIME, function()
self.Backup.Parent = self.Instance.Parent
self.Instance:Destroy()
end)
end)
end
I tried the ApplyImpulse but it had really negative effects
You should try helping the process by using ApplyImpulse() on the light pole. That way there’s an almost 100% chance it will fall down, heck, even go flying if that’s what you want.
Are you applying it on the pole? also, you may need to up the force, or down it. One last thing, are you applying it in the right direction? I almost forgot, there are other methods of apply forces to objects, and you could try those, too.
Well from my limited knowledge on Vector3’s, to me it looks like I’m applying the force in the same direction the car moves (so when you hit it, it actually looks like it’s been hit. But it’s flipping the car out
Set all the parts on the light pole to massless and then set primarypart (the invis part that detects hit) to have 2 density
Unsure how it’s falling through the map. They get their collision group set to Destructible, which has collisions with Default set to true. Only thing it should pass through is the vehicle parts
-- Unanchor the model (so it falls over)
for _, part in self.Instance:GetDescendants() do
if not part:IsA("BasePart") then
continue
end
part.Anchored = false
PhysicsService:SetPartCollisionGroup(part, "Destructible")
end
self.Instance.PrimaryPart:ApplyImpulse(CFrame.new(hit.Position, self.Instance.PrimaryPart.Position).LookVector.Unit * 20)
I disable collisions. I don’t want the light to make the car stop. The car should pass through as it falls
That’s the point of the impulse. To make the light fall over without the car needing to physical push it over. When collisions are on, the car either hits the pole and gets stopped by the pole, which ruins UX or the pole falls awkwardly on the car, making the car stop anyway. User should be able to drive straight through with nothing interacting with their car to cause it to slow down/stop
Ah, I have an idea. This has to do with the massless property. use a WeldConstraint on an invisible unanchored part onto it then size it to your liking, and then make the actual pole massless. The reason for this is because massless only applies for welds. You would use it to ignore the weight of some parts in a weld, and consider the weight of others. So here, make a “weld” and then ignore the weight of the pole, but consider the weight of the part. If it is too light, make the part bigger.
Also, try aligning the invis part with the pole, so that physics don’t seem off.
properties for the invisible part:
properties for the pole:
Here’s how it looks, the red part is the pole the green part is the invis part:
You can change the positions and stuff, too. Even put the green part inside the red part.