Hello, I’m currently trying myself on an explosion system and my question is:
How do I make a part “blow” away from a specific position/part?
If you didn’t understand what I mean, here is a nice paint picture:
Green: Velocity directions
Blue: Parts that are flying away (because of the “blow” that is coming from red)
Red: Explosion Position
Thanks for helping!
1 Like
You could use the shiny new BasePart | Roblox Creator Documentation method to apply a force, instead of a velocity. That way heavier objects move less.
Divide by the distance from the explosion squared to make closer parts fly away faster.
Something like
local POWER = 1000
local offset = part.Position - explosionPosition
local distance = offset.Magnitude
if distance < 20 then -- some maximum limit
part:ApplyImpulse(POWER * offset.Unit / (distance * distance))
end
2 Likes
Is there a way to do this with velocity? Btw I got a table of the parts that should fly away…
Thanks for helping, but I found a soloution:
PartToBlowAway.Velocity = (PartToBlowAway.Position - ExplosionPosition) * speed
1 Like
The funny thing is, that you can also turn the variables in the brackets around to make a kind of magnet effect…