|
| 08 Feb 2016 08:57 AM |
p=script.Parent; x=0;z=0; --initial pos (s0) g=-9.81; --gravity (m/s*s) m=5;v=0;s=25;a=0;f=0; --properties of p (part) t=0;l=tick();
game:GetService("RunService").Stepped:connect(function() t=tick()-l;l=tick(); f=m*g; a=f/m; v=v+a*t; s=s+v*t; s=s<=0 and 0 or s; p.Position=Vector3.new(x,s,z); end)
when i change the "m", which is the mass of the part, it doesn't affects the speed, why is that happening? |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2016 08:58 AM |
| Because you divide by M after multiplying it, cancelling it out. |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2016 09:05 AM |
another question... why it's with a constant velocity? shouldn't it be like a Free Fall? Increasing the velocity? |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2016 09:06 AM |
Also, I don't understand quite what you're doing. Why don't you simplify it to a reasonable Verlet Integration implementation?
// Each frame Velocity += NetForce; Position += Velocity; |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2016 09:10 AM |
Or in Roblox:
local Gravity = Vector3.new(0, -9.8, 0)
local Points = {} local R = math.random for Num = 1, 20 do table.insert(Points, { Position = Vector3.new(R(-100, 100), R(100), R(-100, 100)), Velocity = Vector3.new(R(-15, 15), R(-15, 15), R(-15, 15)) }) end
game.RunService.RenderStepped:connect(function() for Index, Point in next, Points do Point.Velocity = Point.Velocity + Gravity -- Add other forces here, if there are any. Point.Position = Point.Position + Point.Velocity end end |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2016 09:11 AM |
well, it's a simple free fall script i don't want to use V.I. because i don't have the necessary knowings to use it |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2016 09:13 AM |
Well it's really easy. The whole concept is kind of what I summarized. Ignore the math stuff on wikipedia unless you really need it, it's much simpler than that.
Just use force, add it to the velocity, and add velocity to position. The only tough part is figuring out what forces you need, and even that will come easy with practice. |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2016 09:18 AM |
okay, i'll try that thanks, @Jarod but why is the part falling with a constant velocity? |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2016 09:49 AM |
| I'm back. Give me a minute or five and I'll look into it. |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Feb 2016 09:56 AM |
Okay, I looked into it. I couldn't figure it out though. It only stops changing velocity when s<=0.
Try this.
p=script.Parent; x=0;z=0; --initial pos (s0) g=-9.81; --gravity (m/s*s) m=5;v=0;s=25;a=0;f=0; --properties of p (part) t=0;l=tick();
game:GetService("RunService").Stepped:connect(function() t=tick()-l;l=tick(); f=m*g; a=f/m; v=v+a*t; s=s+v*t; p.Position=Vector3.new(x,math.max(s,0),z); end) |
|
|
| Report Abuse |
|
|