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

BodyVelocity on Dummy NPC not working properly?

Asked by 5 years ago

I have a dummy in the workspace, and I tested shooting a part at the player with a bodyvelocity. The problem is, is that it's not even going in the right direction sometimes towards the player, or sometimes it is, it's just crazy. I replaced the BodyVelocity with a BodyPosition to see if the same thing would happen, and the BodyPosition worked, but I just don't find it appealing.

game.Players.PlayerAdded:Connect(function(player)
    local dummy = script.Parent
    local char = game.Workspace:WaitForChild(player.Name)
    while true do

        local p = Instance.new("Part")
        p.Shape = "Ball"
        p.Anchored = false
        p.CanCollide = false
        p.Parent = workspace
        p.CFrame = dummy.Torso.CFrame
        local bv = Instance.new("BodyVelocity")
        bv.Parent = p
        bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
        bv.P = 500
        bv.Velocity = char.Torso.CFrame.p



        wait(5)
    end
end)

I also tried replacing bv.Velocity = char.Torso.Position, and the same thing happened. Any ideas?

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

thats not how velocity works, first off, velocity works in world space, so rotation wont do anything to effect it, second, if you set velocity to the position of a part, then the x, y, and z coordinates will be transformed into velocity which does not work, if you want to make it use a position, you should be using BodyPosition, or at least use math to figure out how to get the position

0
Thanks for the in depth explanation. I did some math by just subtracting the player torso from the dummy torso positions or the other way around. I forgot. But it works now, thanks. ScrubSadmir 200 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

you set the parent of the body velocity to workpsace instead of the dummy's lower torso

0
The parent of the velocity is the part, not the dummys torso. It's solved either way. ScrubSadmir 200 — 5y

Answer this question