Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
NiKxzsu 13
5 years ago

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?

0
Lerp. Lerp is your friend. ee0w 458 — 5y

2 answers

Log in to vote
0
Answered by
oftenz 367 Moderation Voter
5 years ago

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.

0
magnitude doesn't return a vector3 value User#20388 0 — 5y
0
and vector3 returns a matrix and not one number (facts :P) DeceptiveCaster 3761 — 5y
0
magnitude returns a float not a matrix DeceptiveCaster 3761 — 5y
Ad
Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

Use CFrame:lerp

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

Here is an explaination of what lerp does

Answer this question