Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Projectiles, BodyVelocity, lookVector... how to hit my target?

Asked by 14 days ago

So i create and fire a fireball in fron't of the player towards the mouse. My problem is that the fireball travels toward the furthest point in the map the mouse is pointing at, rather than the intended target(enemies/Models)

So for expamle if i was pointing my mouse at a player, yet my camera was looking from above, the fireball would move to the mouse position beyond the player and therefore miss entirely.

thanks in advance

local FireBallClone = FireBall:Clone()
    FireBallClone.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
    FireBallClone.Parent = workspace

    local BodyVelocity = Instance.new("BodyVelocity", FireBallClone)
    BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

    spawn(function()
        for i = 0, 1000 do
            wait()
                FireBallClone.Size = FireBallClone.Size + Vector3.new(0.05,0.05,0.05)
                BodyVelocity.Velocity = Mouse.lookVector * i
    end
end)
0
Use raycasting. Even if your script is super efficient, raycasting will beat it since it is coded in C++. NO seriously, use raycasts. No buts, doesn't matter, raycasts are better. sleazel 394 — 14d

Answer this question