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

Can someone tell me why this projectile is shooting sideways instead of forward?

Asked by 4 years ago
Edited 4 years ago

I have attachments welded to this so effects spiral around it with the AngularVelocity, the effects spiral around it, but the projectile is going sideways instead of forward.

        local RootPart = character.HumanoidRootPart
    projectile.CFrame = CFrame.new(RootPart.CFrame.Position) 
    projectile.Parent = game.Workspace     
        local BA = Instance.new("BodyAngularVelocity", projectile)
    BA.maxTorque = Vector3.new(math.huge,math.huge,math.huge) 
    BA.AngularVelocity = RootPart.CFrame.lookVector*10                      
    local BV = Instance.new("BodyVelocity", projectile)
    BV.maxForce = Vector3.new(math.huge,math.huge,math.huge)
    BV.Velocity = projectile.CFrame.lookVector*100

1 answer

Log in to vote
0
Answered by
TrippyV 314 Donator Moderation Voter
4 years ago
Edited 4 years ago

The problem is that on line 2 you are creating a new CFrame instance from the RootPart's position rather than it's CFrame. This creates a situation where the game's physics chooses a default axis to travel upon because a Position vector doesn't have any kind of rotational information like CFrame does.

To fix this, simply replace line 2 with

projectile.CFrame = RootPart.CFrame

Hope this helped! :)

0
Ohhhh, thank you soooo soooo mcuh!!!! :) That worked! Dorchsaoil 11 — 4y
0
"much" that is. I apparently type about as well as I script. haha Thanks again!! Dorchsaoil 11 — 4y
Ad

Answer this question