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 » Scripting Helpers
Home Search
 

Re: Velocity

Previous Thread :: Next Thread 
ZizZazZuz is not online. ZizZazZuz
Joined: 16 Jun 2008
Total Posts: 2743
28 Feb 2013 06:07 PM
I'm making a script that drops parts around a certain point, within 50 studs. But I don't know the formulas for getting parts to drop in that area using only velocity. Anyone know how it works?
Report Abuse
RenderSettings is not online. RenderSettings
Joined: 16 Aug 2010
Total Posts: 2560
28 Feb 2013 06:11 PM
To make a part accelerate towards a spot, do (pos1-pos2).unit*speed. For example:

part = WhateverYouNeedToAccelerate

part.Velocity=(pos+Vector3.new(math.random(-50,50),0,math.random(-50,50))-part.Position).unit*part:GetMass()*something

With pos being the area you want it to go to, and something the speed for the part
Report Abuse
ZizZazZuz is not online. ZizZazZuz
Joined: 16 Jun 2008
Total Posts: 2743
28 Feb 2013 06:17 PM
Oh, thanks!
Report Abuse
M0RGOTH is not online. M0RGOTH
Joined: 13 Mar 2010
Total Posts: 62
28 Feb 2013 07:30 PM
If you want the parts to fall with gravity, just unanchor them. If you want them to fall with a specific velocity, do this:

local velocity = 5 --some speed (stud/second)
local part = workspace.Part --the path to your part
part.Velocity = Vector3.new(0,-speed,0)

If you want the part to fall with a random velocity, do this:

math.randomseed(tick()) --makes it so that every time your level is loaded the random numbers are different
local min = 1 --minimum speed (stud/second)
local max = 5 --maximum speed (stud/second)
local part = workspace.Part --the path to your part
part.Velocity = Vector3.new(0,-math.random(min,max),0)

If you want the parts to spawn randomly in an area you could do something like this:

local dimensions = Vector2.new(10,10) --the 2d dimensions of your spawning area
local position = Vector3.new(0,10,0) --the center of your spawning area
local partCount = 5 --however many parts you want to spawn
for i = 1, partCount do
   local part = Instance.new("Part",workspace)
   part.Anchored = true --if you want them to fall by gravity just remove this line
   part.Position = position + Vector3.new(math.random(dimensions.X),0,math.random(dimensions.Y))

   --put the code from the other 2 options in here to set the part's velocity or just leave it blank if you are using the gravity method
end


@RenderSettings I only posted this because I am not sure that your post did what his question was asking for.
Report Abuse
TerminatorUNLRASHED is not online. TerminatorUNLRASHED
Joined: 28 Jan 2010
Total Posts: 365
28 Feb 2013 07:51 PM
Oh that is soooo easy. Simply use body position.
Report Abuse
doneyes is not online. doneyes
Joined: 21 Mar 2008
Total Posts: 3466
28 Feb 2013 08:26 PM
Body position isn't as consistent though, is it?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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