generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Make object fly away relative to a position

Previous Thread :: Next Thread 
wil7vin is not online. 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
AbsoluteLOL is not online. AbsoluteLOL
Joined: 01 Dec 2012
Total Posts: 3939
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
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
28 Dec 2012 01:03 PM
You can achieve this with CFrames.
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
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 is not online. wil7vin
Joined: 09 Mar 2009
Total Posts: 21
28 Dec 2012 01:45 PM
Thanks man :P
Report Abuse
Abasiophilia is not online. Abasiophilia
Joined: 09 Sep 2012
Total Posts: 99
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
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
28 Dec 2012 02:07 PM
Velocity isn't constant. The physics engine will massacre you.
Report Abuse
Abasiophilia is not online. Abasiophilia
Joined: 09 Sep 2012
Total Posts: 99
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
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
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
Abasiophilia is not online. Abasiophilia
Joined: 09 Sep 2012
Total Posts: 99
29 Dec 2012 01:34 PM
@Doombringer

But it's not an explosive, it's a high-pressure invisible sphere!
Report Abuse
NVI is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image