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

How would I fine tune this velocity?

Asked by 9 years ago

Hello! I am in the progress of creating a bomb much lik it is in the Legend of Zelda series. I am useing the default gear "Fuse Bomb". I am trying to make the bomb be thrown when activated. I made this velocity part that seems to work but it does not go the direction I want it to go. Here is the script I don't know how to tune

bombScript = script.Parent.Bomb
Tool = script.Parent

function plant(pos)


    local vCharacter = Tool.Parent
    local vPlayer = game.Players:playerFromCharacter(vCharacter)

    local spawnPos = vCharacter.PrimaryPart.Position

-- not important above
    local bomb = Tool.Handle:Clone()
    bomb.CanCollide = true
    bomb.Transparency = 0
    bomb.Position = pos
    bomb.Size = Vector3.new(2,2,2)
    bomb.Name = "FuseBomb"
    bomb.Locked = true
    bomb.Velocity = bomb.CFrame.lookVector * 20 -- this makes it go to the left. I need it to go forwards.
--not important below   

    local spark = Instance.new("Sparkles")
    spark.Name = "Fuse"
    spark.Parent = bomb


    local creator_tag = Instance.new("ObjectValue")
    creator_tag.Value = vPlayer
    creator_tag.Name = "creator"
    creator_tag.Parent = bomb

    bomb.Parent = game.Workspace
    local new_script = bombScript:clone()
    new_script.Disabled = false
    new_script.Parent = bomb

end


Tool.Enabled = true
function onActivated()

    if not Tool.Enabled then
        return
    end

    Tool.Enabled = false

    local character = Tool.Parent;
    local humanoid = character.Humanoid
    if humanoid == nil then
        print("Humanoid not found")
        return 
    end

    local targetPos = humanoid.TargetPoint

    Tool.Handle.Transparency = 1
    plant(Tool.Handle.Position)
    wait(3)
    Tool.Handle.Transparency = 0

    Tool.Enabled = true
end


script.Parent.Activated:connect(onActivated)

Is there a way to make this go a different way still using LookVector?

Thanks! ~Minikitkat

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

Use the Torso's lookVector instead

bomb.Velocity = vCharacter.Torso.CFrame.lookVector * 20
0
Okay thanks! I never would have thought of doing that! minikitkat 687 — 9y
Ad

Answer this question