|
| 03 Aug 2016 04:54 PM |
This works perfectly fine for linear transition but I'm looking to make it so the Y value increases parabolicly from the start to the finish, starting low, growing rapidly, topping off, and then lowering onto he final result
local x0 = 10 local y0 = 10 local z0 = 10 local target = Vector3.new(20,20,20) for i = 0,1,.1 do local x = x0 + (target.X-x0)*i local y = y0 + (target.Y-y0)*i local z = z0 + (target.Z-z0)*i print(x,y,z) end
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
|
| 03 Aug 2016 04:58 PM |
| Not sure if posting obvious or stating something obvious i should be doing. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
|
| 03 Aug 2016 05:04 PM |
| Already did, turns it into an exponential function, Not a parabola saddly |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
|
| 03 Aug 2016 05:08 PM |
| Already did that, Turns it into an exponential function that goes way beyond the target. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:10 PM |
| I could try making the i variable change parabolicly/ exponentially but Idk how lol |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Aug 2016 05:11 PM |
for x = 0,10 do local y = x^2 --code end
|
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:14 PM |
It would be a little more like this lol
y = -(x-.5)^2 + .25 |
|
|
| Report Abuse |
|
|
| |
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 03 Aug 2016 05:17 PM |
If your x goes negative, to prevent Y from going negative; use Math.abs(7).
Math.abs will positive anything inside the parenthesis. |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 03 Aug 2016 05:17 PM |
| Math.abs(Y)* the 7 was a mistype. |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 03 Aug 2016 05:19 PM |
Example:
x = 3 y = 2
x = 2 y = 1
x = 0 y = -1 -> but Math.abs(y), here = 1 because Math.abs convert your number to positive. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:24 PM |
If what I'm reading is true, you want a function that creates an arc (in which the arc starts and ends at 0, and goes a certain distance (at which half of that distance is the highest point the function will output). If so, then try this equation:
y=(-(x-a/2)^2)/(a^2/4/b)+b
where y is the returned value, x is the input value, a is the total length, and b is the maximum height.
(Strive to improve and inspire. <-> Be inspired by those who strive to become better.) The circle of inspiration. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:28 PM |
Ill try what you said but just to be clear heres my goal,
Im trying to make a part go though the air like its been thrown like a ball straight up, I know my final desination and I know where I begin, so I thought tweening would be the best option.
I was able to do it perfectly linearly, but I would like the y axis to go way above the point than drop back down to my target. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:31 PM |
Didn't quite understand how to impalent your question but I tried, and failed.
local x0 = 10 local y0 = 10 local z0 = 10 local target = Vector3.new(20,20,20) for i = 0,1,.1 do local x = x0 + (target.X-x0)*i local y = y0 + (target.Y-y0)*i local a = (target.Y-y0) y = (-(i-a/2)^2)/(a^2/4/(a+10))+a+10 local z = z0 + (target.Z-z0)*i print(x,y) end
10 0 -- should start at 10, shouldn't it? 11 0.79199999999999 12 1.568 13 2.328 14 3.072 15 3.8 16 4.512 17 5.208 18 5.888 19 6.552 20 7.2 |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:33 PM |
Should've said this earlier.
10,10 11,12 12,14 13,18 14,26
ect.. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:34 PM |
Yup, that sound like an arc. Let me write a quick function to format w/ lerping:
local function arc(i,len,height) if 0<=i and i<= 1 return y=(-(len*i-len/2)^2)/(len^2/4/height)+height else return 0 --failsafe so that i has to be in the standard lerping range end end
(Strive to improve and inspire. <-> Be inspired by those who strive to become better.) The circle of inspiration. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:40 PM |
P.S. The function only gives a change in y, so add it to the default y (base).
example: for i=0,10 do print(i/10,arc(i/10,2,1) end
Output: 0,0 .1,.36 .2,.64 .3,.84 .4,.96 .5,1 .6,.96 .7,.84 .8,.64 .9,.36 1,0
(Strive to improve and inspire. <-> Be inspired by those who strive to become better.) The circle of inspiration. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:42 PM |
look up bezier curves
Add 13,000 posts |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:45 PM |
| Thanks sean I dont know how I would've came up with that myself |
|
|
| Report Abuse |
|
|