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

How would I convert these bodymovers into CFrames?

Asked by 8 years ago
        local bodyForce = Instance.new('BodyForce', part)
        bodyForce.Name = 'Antigravity'
        bodyForce.force = Vector3.new(0, part:GetMass() * 196.8, 0)

        local spawnPosition = (handle.CFrame * CFrame.new(2, 0, 0)).p
        part.CFrame = CFrame.new(spawnPosition, mouse.Hit.p) 

        part.Velocity = part.CFrame.lookVector * bulletvelocity
        part.Parent = workspace

So I made a bullet script, but it uses Bodymovers. And as you can tell, these lag. A lot. So my question is, how would I convert this into CFrame to make it less laggy>?

1 answer

Log in to vote
1
Answered by
4Bros 550 Moderation Voter
8 years ago

By convert to CFrame, do you mean keep the part anchored and just use cframe to move it? If that's the case, then this is your answer.

local spawnCFrame = (handle.CFrame * CFrame.new(2, 0, 0)) 
local cframe  = CFrame.new(mouse.Hit.p)  -- CFrame of mouse
part.Parent = workspace
part.Position = spawnCFrame.p -- Position the part to the spawncframe
for i = 0,1,.1 do --Put in your increment
    part.CFrame = spawnCFrame:lerp(cframe,i) -- Will tween the part to the cframe with i as the fraction alpha
    wait()
end
Ad

Answer this question