|
| 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 |
|
|
|
| 15 Nov 2014 09:26 PM |
| Vector3_1:lerp(Vector3_2, Alpha) |
|
|
| Report Abuse |
|
|
|
| 15 Nov 2014 09:30 PM |
| so technically, it's basically the distance formula between two Vectors? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|