|
| 12 Apr 2016 05:04 PM |
How would I make it so that, using CFrame, I could move an object from pos1 to pos2 using a quadratic equation?
Instance.new("BodyThrust",SenseiWarrior).position = CFrame.new(SenseiWarrior,YourGirlsDMs) |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 05:05 PM |
| do u mean like move it in a curve? |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 05:06 PM |
thats what a parabola is yes
Instance.new("BodyThrust",SenseiWarrior).position = CFrame.new(SenseiWarrior,YourGirlsDMs) |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 05:08 PM |
ya but like a parabola is like a 2d thing
which way would the object curve in 3d space? would it curve up? down? left? right? |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 05:10 PM |
up
Instance.new("BodyThrust",SenseiWarrior).position = CFrame.new(SenseiWarrior,YourGirlsDMs) |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 05:17 PM |
| Well I think it would still be possible by CFraming ,but it would be ugly. Because eventhough we are programming in a 3d world we can use 2D for the CFraming by only using like for example the Position x and y or z and y etc. |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 05:18 PM |
| I would try getting some points then lerping/interpolating |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 05:18 PM |
then i would just add y coordinates to a normal cframe tweening function
and u could use the parabolic equation to figure out how high the y |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 05:20 PM |
| Interpolate to find the vertex. Then use a rays to connect the vertex to the 2 endpoints. |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 05:27 PM |
| Oh I did not know you mentioned you wanted to 'move' the object if that's the case discard my idea about the Rays and instead move the part towards the vertex. The vertex would be determined by using a function I cannot remember but it takes in two points the parabola passes through which in this case would be pos1 and pos2 and will output the vertex from there you will move your part from pos1 to vertex and vertex to pos2. |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 05:33 PM |
| nvm after searching it's not mathematically possible given two points. Because if all you're given is two there are infinitely many parabolas that pass through those two points. |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 05:44 PM |
local pos1 = Vector3.new(x1, y1, z1) local pos2 = Vector3.new(x2, y2, z2) local offset = pos2 - pos1 local dx, dy, dz = offset.X, offset.Y, offset.Z local height = 10
local midpt = pos1:Lerp(pos2, 0.5) local vertex = Vector3.new(midpt.x, dy+height, midpt.z)
So each y point would be: -height*(x-vertex.X)^2 + vertex.Y Hopefully I did that correctly |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Apr 2016 05:54 PM |
| There may be infinite many parabolas, but there will only be 1 that has that height :) |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Apr 2016 06:07 PM |
local part, origin, a, b, c, x, y = Instance.new("Part",workspace), Vector3.new(0,0,0), 1, --ax^2 1, --+bx 0 --+c
y = function(x)return (a*x^2)+b*x+c end
for i=-10,10 do part.Position = Vector3.new(x,1,y(x))+Origin wait(.1) end
Perhaps? |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2016 06:26 PM |
| @Flux yeah I completely forgot about defining one's own vertex. |
|
|
| Report Abuse |
|
|