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 |
|
|
|
| 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
|
  |
| Joined: 16 Jun 2008 |
| Total Posts: 2743 |
|
| |
|
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 |
|
|
|
| 28 Feb 2013 07:51 PM |
| Oh that is soooo easy. Simply use body position. |
|
|
| Report Abuse |
|
|
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 |
|
|