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 » Scripting Helpers
Home Search
 

Re: Special Function

Previous Thread :: Next Thread 
AlphaNebula is not online. AlphaNebula
Joined: 23 Sep 2008
Total Posts: 545
15 Nov 2014 09:24 PM
Is there any special CFrame function or of the such that moves an object/model from Vector3 a to Vector3 b in a sliding manner?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
15 Nov 2014 09:26 PM
Vector3_1:lerp(Vector3_2, Alpha)
Report Abuse
AlphaNebula is not online. AlphaNebula
Joined: 23 Sep 2008
Total Posts: 545
15 Nov 2014 09:30 PM
so technically, it's basically the distance formula between two Vectors?
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
15 Nov 2014 09:31 PM
no idea if the 'time' part works but I made this (using lerp would be better but Im posting this anyway ok)


function tweenPart(part, position, x)
local add = (part.Position - position) / ((part.Position - position).magnitude * ((x or (part.Position - position).magnitude) * 0.03))
for _ = 1, ((part.Position - position).magnitude * ((x or (part.Position - position).magnitude) * 0.03)), 1 do
part.CFrame = part.CFrame - add
wait(0.03)
end
part.CFrame = part.CFrame + (-part.CFrame.p + position)
end

local part = Instance.new("Part", workspace)
part.Anchored = true
tweenPart(part, Vector3.new(50, -75, 100), 3)
--[[tweenPart(part, position, time)
part is the part to move
position is the place to move to
time is how long it can take to get there
]]
Report Abuse
AlphaNebula is not online. AlphaNebula
Joined: 23 Sep 2008
Total Posts: 545
15 Nov 2014 09:34 PM
That works perfectly actually. Thanks, I should be able to apply it to a model aswell.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
15 Nov 2014 11:48 PM
The time still doesn't seem to work but here is one with lerp

local function tweenPart(o, p, t)
local add = o.Position:lerp(p, 0.03 / (t or (o.Position - p).magnitude))
for _ = 1, (t or (o.Position - p).magnitude) / 0.03 do
o.CFrame = o.CFrame + add
wait(0.03)
end
print(tick() - a)
o.CFrame = o.CFrame + (-o.Position + p)
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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