wil7vin
|
  |
| Joined: 09 Mar 2009 |
| Total Posts: 21 |
|
|
| 28 Dec 2012 12:55 PM |
Hi scripters of roblox,
so lets keep it short shall we i want to make a object fly away from a set position
it is for a explosion like script but dude to things in my script i can't use a actual explosion to make stuff fly away.
to explain further i want a part to fly away relative to a other position so if a part is on the left side of the position it fly's to the left and if a part is on the other side it needs to fly to the right.
if anybody knows how to do this please say how this can be done ? |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2012 12:56 PM |
*reads title* Oh! An intelligent discussion. *reads OP* wat
Get out. You failed to use any form of proper grammar and posted this in the wrong section. OUT. |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2012 01:03 PM |
| You can achieve this with CFrames. |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2012 01:09 PM |
part.Velocity = (origin - part.Position).unit * velocity you might have to look into the maths for that more, but that's the basic idea. |
|
|
| Report Abuse |
|
|
wil7vin
|
  |
| Joined: 09 Mar 2009 |
| Total Posts: 21 |
|
| |
|
|
| 28 Dec 2012 01:52 PM |
@Previous Code
It'd actually be part.Velocity = -(origin - part.Position).unit * velocity, otherwise you'd have a black hole. |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2012 02:07 PM |
| Velocity isn't constant. The physics engine will massacre you. |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2012 01:28 PM |
I don't know why I spent so much time on this, but it sure was fun! Sorry for the bump, but here is a script.
local Bomb = script.Parent local Table = {} local Distance = 20 local Velocity = 400 function explode() function Check(Item) if Item:IsA("Part") and Item ~= Bomb then if Item.Anchored ~= true and (Item.Position - Bomb.Position).magnitude < Distance then table.insert(Table, 1,Item) end elseif Item:IsA("Model") or Item:IsA("Hat") or Item:IsA("Tool") or Item == game.Workspace then local Child = Item:GetChildren() for i = 1, #Child do Check(Child[i]) end end end Check(game.Workspace) for a = 1, #Table do Table[a]:BreakJoints() Table[a].Velocity = -(Bomb.Position - Table[a].Position).unit * Velocity end end wait(2) explode() |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2012 01:30 PM |
| you need to account for the fact that velocity is increased at closer distances to the explosion's origin. |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2012 01:34 PM |
@Doombringer
But it's not an explosive, it's a high-pressure invisible sphere! |
|
|
| Report Abuse |
|
|
NVI
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 4744 |
|
|
| 29 Dec 2012 01:59 PM |
| This reminds me of that terrible boulder thing I scripted for King of the Hill on builderman's account... |
|
|
| Report Abuse |
|
|
eJorge
|
  |
| Joined: 09 Jun 2011 |
| Total Posts: 5966 |
|
|
| 29 Dec 2012 02:12 PM |
function getPartsWithin(center, studs) local parts = {} local function getParts(object) for _, child in pairs(object:GetChildren()) do if child:IsA("BasePart") and (center-child.Position).magnitude <= studs then parts[#parts+1] = child end getParts(child) end end getParts(workspace) return parts end
function bomb(pos, radius, pressure) local explosion = Instance.new("Explosion") explosion.BlastPressure = 0 explosion.Position = pos explosion.BlastRadius = radius explosion.Parent = workspace local parts = getPartsWithin(pos, radius) for _, part in pairs(parts) do if not part.Anchored then --To prevent random conveyor belts part.Velocity = -(pos-part.Position).unit * (radius-((pos-part.Position).magnitude*radius/pressure)) --ye end end end
--That was fun. |
|
|
| Report Abuse |
|
|