|
| 20 Aug 2015 08:13 PM |
I want to cframe a brick from point A to point B, but I want it to have a parabola. The vertex will be on top. This is supposed to simulate a missle launch (for a DEFCON game)
what would be more efficient?
Using an equation to loop through all the vector plots or using cframe:lerp()?
ʏᴏᴜ ᴛʜᴏᴜɢʜᴛ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴅʀᴀɢ ᴍᴇ ᴛᴏ ᴛʜᴇ ʙᴏᴛᴛᴏᴍ ᴏғ ᴛʜᴇ ʟᴀᴋᴇ sᴏ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴇᴀᴛ ᴍᴇ ʟᴀᴛᴇʀ... ᴡᴇʟʟ ɢᴜᴇss ᴡʜᴀᴛ ᴘᴜɴᴋ... ɪᴍ ᴀ ғɪsʜ... ᴡɪᴛʜ ʟᴇɢs |
|
|
| Report Abuse |
|
|
wurzer
|
  |
| Joined: 08 Jul 2015 |
| Total Posts: 71 |
|
| |
|
|
| 20 Aug 2015 08:46 PM |
b
ʏᴏᴜ ᴛʜᴏᴜɢʜᴛ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴅʀᴀɢ ᴍᴇ ᴛᴏ ᴛʜᴇ ʙᴏᴛᴛᴏᴍ ᴏғ ᴛʜᴇ ʟᴀᴋᴇ sᴏ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴇᴀᴛ ᴍᴇ ʟᴀᴛᴇʀ... ᴡᴇʟʟ ɢᴜᴇss ᴡʜᴀᴛ ᴘᴜɴᴋ... ɪᴍ ᴀ ғɪsʜ... ᴡɪᴛʜ ʟᴇɢs |
|
|
| Report Abuse |
|
|
| |
|
AstroCode
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 1122 |
|
|
| 20 Aug 2015 08:53 PM |
From what I understand, you already have the parabola points, and you just need to move the missile to the points? If this is the case, then I would suggest using cframe:lerp()
for i, v in next, points do for k = 0.1, 1 , 0.1 do missile.CFrame = missile.CFrame:lerp(v.CFrame, k) wait() end end
|
|
|
| Report Abuse |
|
|
|
| 20 Aug 2015 08:59 PM |
Astro thats just going to smoothly tween a part from A to B
in a parabola, there is two points that intersect the X axis. There is also a vertex, I want my vertex to be a in the shape of a "∩"
ʏᴏᴜ ᴛʜᴏᴜɢʜᴛ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴅʀᴀɢ ᴍᴇ ᴛᴏ ᴛʜᴇ ʙᴏᴛᴛᴏᴍ ᴏғ ᴛʜᴇ ʟᴀᴋᴇ sᴏ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴇᴀᴛ ᴍᴇ ʟᴀᴛᴇʀ... ᴡᴇʟʟ ɢᴜᴇss ᴡʜᴀᴛ ᴘᴜɴᴋ... ɪᴍ ᴀ ғɪsʜ... ᴡɪᴛʜ ʟᴇɢs |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2015 09:10 PM |
k i'm using lerp
i'm using ax^2 + bx = c and i'm going to use the x's to loop.
ʏᴏᴜ ᴛʜᴏᴜɢʜᴛ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴅʀᴀɢ ᴍᴇ ᴛᴏ ᴛʜᴇ ʙᴏᴛᴛᴏᴍ ᴏғ ᴛʜᴇ ʟᴀᴋᴇ sᴏ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴇᴀᴛ ᴍᴇ ʟᴀᴛᴇʀ... ᴡᴇʟʟ ɢᴜᴇss ᴡʜᴀᴛ ᴘᴜɴᴋ... ɪᴍ ᴀ ғɪsʜ... ᴡɪᴛʜ ʟᴇɢs |
|
|
| Report Abuse |
|
|
AstroCode
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 1122 |
|
|
| 20 Aug 2015 09:18 PM |
Ewwwww algebra XD
I can't remember much from that course. |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2015 10:28 PM |
So this is the crap i made so far, still WIP
function launchMissle(MissileOrigin, TargetEnd) local ICBM = game.ReplicatedStorage:FindFirstChild("ICBM") or error("Missle is missing") ICBM.Material = Enum.Material.Neon ICBM.BrickColor = BrickColor.new("Institutional white") ICBM.Position = MissileOrigin local ICBM_Magnitude = (MissileOrigin - TargetEnd).magnitude/25 for X = 1, ICBM_Magnitude*12 do local TrinomialA = Vector3.new( 0, (A*(X/ICBM_Magnitude)^2) + (B*(X/ICBM_Magnitude)) + C, 0 ) local TrinomialB = Vector3.new( 0, (A*((X+1)/ICBM_Magnitude)^2) + (B*(X+1)/ICBM_Magnitude) + C, 0 ) local ICBM_CFrame = CFrame.new( ICBM.Position:lerp(TargetEnd, (X/ICBM_Magnitude)) + TrinomialA, ICBM.Position:lerp(TargetEnd, ((X+1)/ICBM_Magnitude)) + TrinomialB ) end end
ʏᴏᴜ ᴛʜᴏᴜɢʜᴛ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴅʀᴀɢ ᴍᴇ ᴛᴏ ᴛʜᴇ ʙᴏᴛᴛᴏᴍ ᴏғ ᴛʜᴇ ʟᴀᴋᴇ sᴏ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴇᴀᴛ ᴍᴇ ʟᴀᴛᴇʀ... ᴡᴇʟʟ ɢᴜᴇss ᴡʜᴀᴛ ᴘᴜɴᴋ... ɪᴍ ᴀ ғɪsʜ... ᴡɪᴛʜ ʟᴇɢs |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2015 11:05 PM |
It would probably be easier for you to just set a launch angle or speed and calculate the other one, using some projectile equations.
Just move the thing like you would a particle, essentially
local GRAVITY = Vector2.new(0, 0, 0)
local pos = Vector3.new(0, 0, 0) local velocity = Vector3.new(100, 100, 0) --would calculate from launch angle + target distance while wait() do pos = pos + velocity velocity = velocity + GRAVITY --move GUI to pos end
~Upload code to codepad-dot-org with Lua syntax highlighting to preserve indentation and make it easier to read!~ |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2015 11:08 PM |
Yeah but the Missles are anchored. If I were to calculate the missle's projection it would lag the client asf
its a minature missle, it isn't like 200x200x200, its like 0.2x1x0.2
ʏᴏᴜ ᴛʜᴏᴜɢʜᴛ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴅʀᴀɢ ᴍᴇ ᴛᴏ ᴛʜᴇ ʙᴏᴛᴛᴏᴍ ᴏғ ᴛʜᴇ ʟᴀᴋᴇ sᴏ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴇᴀᴛ ᴍᴇ ʟᴀᴛᴇʀ... ᴡᴇʟʟ ɢᴜᴇss ᴡʜᴀᴛ ᴘᴜɴᴋ... ɪᴍ ᴀ ғɪsʜ... ᴡɪᴛʜ ʟᴇɢs |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2015 11:09 PM |
I'd also like to point out these are parts in a 3D workspace, nothing of the game will be on GUI's except maybe buying extra tonnage for the user arsenal.
Assuming this from "--move GUI to pos"
ʏᴏᴜ ᴛʜᴏᴜɢʜᴛ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴅʀᴀɢ ᴍᴇ ᴛᴏ ᴛʜᴇ ʙᴏᴛᴛᴏᴍ ᴏғ ᴛʜᴇ ʟᴀᴋᴇ sᴏ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴇᴀᴛ ᴍᴇ ʟᴀᴛᴇʀ... ᴡᴇʟʟ ɢᴜᴇss ᴡʜᴀᴛ ᴘᴜɴᴋ... ɪᴍ ᴀ ғɪsʜ... ᴡɪᴛʜ ʟᴇɢs |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2015 11:39 PM |
I actually found out a complex and nice way to do it
I calculate the midpoint between the two parts and then I CFrame the missle to the midpoint (I curve it a bit) and then to the point B.
the cool this about this is that the Y is actually X2+X1+Distance Between parts.
its a bit more real here.
well yeah thanks guys I appreciate all your help :D
ʏᴏᴜ ᴛʜᴏᴜɢʜᴛ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴅʀᴀɢ ᴍᴇ ᴛᴏ ᴛʜᴇ ʙᴏᴛᴛᴏᴍ ᴏғ ᴛʜᴇ ʟᴀᴋᴇ sᴏ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴇᴀᴛ ᴍᴇ ʟᴀᴛᴇʀ... ᴡᴇʟʟ ɢᴜᴇss ᴡʜᴀᴛ ᴘᴜɴᴋ... ɪᴍ ᴀ ғɪsʜ... ᴡɪᴛʜ ʟᴇɢs |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2015 11:52 PM |
But I made you a pretty drawing https://www.desmos.com/calculator/pfqolcdyyr
~Upload code to codepad-dot-org with Lua syntax highlighting to preserve indentation and make it easier to read!~ |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2015 11:56 PM |
local a = 1 local b = 0 local c = 5 for x=1,10 do obj.CFrame = CFrame.new(x,a*(x^2)+b*x+c,0) end
try that as a demo |
|
|
| Report Abuse |
|
|