I am trying to make an ability similar to the one shown in this video:
The issue I am running into it while creating it, I want it so, like the video, the rocks start coming out at the players position, and then start coming out of the ground while still forming a line with each other and not just teleporting to the mouses position.
Here is a video of what I’ve tried already.
As you can see, I’ve got the base of it done, and I tried implementing the limiter but when you move your mouse across the screen it still leaves major gaps.
Script:
--# PARAMETERS
local raycastParameters = RaycastParams.new()
raycastParameters.FilterType = Enum.RaycastFilterType.Exclude
raycastParameters.FilterDescendantsInstances = { workspace:FindFirstChild('Interactables') }
--# RAYCAST
local rootRaycast = workspace:Raycast(HumanoidRootPart.Position, Vector3.new(0, -4, 0), raycastParameters)
--# ROCKS
local lastPosition = rootRaycast.Position or HumanoidRootPart.Position
for i = 1, Ability.details['surge_time'], Ability.details['surge_rate'] do
--# SPAWN
task.spawn(function()
--# RAYCAST
local raycast = workspace:Raycast((mouse_position + Vector3.new(0, 1, 0)), Vector3.new(0, -999, 0), raycastParameters)
if (raycast) then
--# POSITIONING
local size = Ability.details['start_size'] * (i * Ability.details['size_factor'])
local actualPosition = nil
--# DISTANCE
local distance = (lastPosition - raycast.Position).Magnitude
local maxDistance = (i^Ability.details['size_factor'])
if (distance > maxDistance) then
actualPosition = lastPosition:Lerp(raycast.Position, (maxDistance / distance))
else
actualPosition = raycast.Position
end
--# ADD
actualPosition += Vector3.new(0, 2, 0)
--# SET
lastPosition = raycast.Position
--# (AT THIS POINT AN EVENT IS FIRED THAT CREATES THE PART ON THE CLIENT)
--# AWAIT
task.wait(Ability.details['surge_rate'])
end
end
['surge_time'] = 4,
['surge_rate'] = 0.05,
['start_size'] = Vector3.new(2, 3, 2),
['size_factor'] = 1.25,