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: How to make this a parabolic function?

Previous Thread :: Next Thread 
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
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 is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
03 Aug 2016 04:55 PM
y = x^2


Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Aug 2016 04:58 PM
Not sure if posting obvious or stating something obvious i should be doing.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
03 Aug 2016 05:01 PM
try i^2


Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Aug 2016 05:04 PM
Already did, turns it into an exponential function, Not a parabola saddly
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
03 Aug 2016 05:04 PM
(target.X-x0)^2*i

try that


Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Aug 2016 05:08 PM
Already did that, Turns it into an exponential function that goes way beyond the target.
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Aug 2016 05:10 PM
I could try making the i variable change parabolicly/ exponentially but Idk how lol
Report Abuse
TimeTicks is not online. 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
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Aug 2016 05:14 PM
It would be a little more like this lol

y = -(x-.5)^2 + .25
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Aug 2016 05:14 PM
Damnit didnt work.
Report Abuse
crate109 is not online. 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 is not online. 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 is not online. 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
seanbenish is not online. seanbenish
Joined: 31 Jul 2009
Total Posts: 429
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
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
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
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
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
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Aug 2016 05:33 PM
Should've said this earlier.


10,10
11,12
12,14
13,18
14,26

ect..
Report Abuse
seanbenish is not online. seanbenish
Joined: 31 Jul 2009
Total Posts: 429
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
seanbenish is not online. seanbenish
Joined: 31 Jul 2009
Total Posts: 429
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
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
03 Aug 2016 05:42 PM
look up bezier curves


Add 13,000 posts
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Aug 2016 05:45 PM
Thanks sean I dont know how I would've came up with that myself
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