Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

CFraming (or whatever) is making me insane. Help?

Let's say there's part a in workspace in position (-59,7,41) and part b in position (-79,13,48). How do I place part c exactly between part a and b?

1 comment

0

Lerp. Lerp is your friend.

2 answers

Hey I attempted using magnitude and the midpoint formula. Didn't work too well,however. If anyone else would like my code here you go:

local start = game.Workspace.start.Position
local poop = game.Workspace.poop.Position  
local newpos = start+poop
local magnitude = (start - poop).magnitude
local magnitudee = magnitude/2
local part = Instance.new("Part", game.Workspace) 
part.Position = Vector3.new(CFrame.new(newpos -magnitudee))

Yeah it's messy because I couldn't find a correct solution. Interested in the correct answer.

3 comments

0

magnitude doesn't return a vector3 value

0

and vector3 returns a matrix and not one number (facts :P)

0

magnitude returns a float not a matrix

Use CFrame:lerp

partC.CFrame = partA.CFrame:lerp(partB.CFrame, 0.5)

Here is an explaination of what lerp does

This discussion is preserved as it was. New answers, comments, and votes are closed.