Hello. I am trying to make a sonic boom effect which includes a sound effect and a cone that moves outwards from the player position. How would I make this cone move away from the player from the opposite direction they’re moving towards?
visualized**
By the way, here is the current code I have (only the code for setting the cone cframe)
function repeatfunction(f,args,t) --repeats the given function every heartbeat for t seconds
local current = tick()
local i = 0
repeat
i += 1
f(i)
rs.Heartbeat:Wait()
until math.abs(tick()-current)>=t
return
end
repeatfunction(function(i)
local hrp = char:WaitForChild("HumanoidRootPart")
local cf = hrp.CFrame
local pos = cf.Position
--part.CFrame = CFrame.lookAt(pos+(cf.LookVector*-(15+(i*2))),pos)*CFrame.Angles(math.rad(-90),0,0)
part.CFrame = CFrame.lookAt(pos-(hrp.Velocity),pos)*CFrame.Angles(0,math.rad(180),0)
end,nil,2)
I already have all the code in for detecting the players speed and all of that. All I need is to find a way to get a vector for the direction the player is moving in. Like CFrame.LookVector. I tried velocity, but if the player moves fast, then the cone position will be super far away.