Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local slimeModel = PartByName("Slime")
- local completedSteps = 0
- local time = 0
- local lastJump = -100
- function lerp(a, b, c)
- return a + (b - a) * c
- end
- function quadBezier(t, p0, p1, p2)
- local l1 = lerp(p0, p1, t)
- local l2 = lerp(p1, p2, t)
- local quad = lerp(l1, l2, t)
- return quad
- end
- function createSlime(name)
- local slime = slimeModel.Duplicate()
- slime.name = name.."Slime"
- return slime
- end
- function calculateSteps(start,finish)
- local steps = {}
- local strideLength = 2
- local distance = Vector3.Distance(start,finish)
- local direction = (finish-start).normalized
- local numSteps = math.ceil(distance/strideLength)
- for i = 1,numSteps do
- steps[i] = start + direction*strideLength*i
- end
- return steps
- end
- function InitialPlayerSpawn(player)
- end
- local slime = createSlime("Quantum")
- local start = newVector3(0,0,0)
- local finish = newVector3(16,0,0)
- local steps = calculateSteps(start,finish)
- local currentStep = 1
- local currentIteration = 0
- slime.position = start + newVector3(0,slime.size.y/2 + .05,0)
- function Update()
- time = time + 1/60
- local point = quadBezier(
- currentIteration/60,
- slime.position,
- slime.position + newVector3(0,1,0)
- steps[currentStep]
- )
- slime.position = point
- currentIteration = currentIteration + 1
- if currentIteration >= 61 then
- currentIteration = 0
- currentStep = currentStep + 1
- end
- if (time - lastJump) > 1 then
- lastJump = time
- slime.position = (steps[completedSteps + 1]) + newVector3(0,slime.size.y/2 + .05,0)
- completedSteps = completedSteps + 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement