-
What do you want to achieve? I want when the projectile arrives at a ramp it goes up
-
What is the issue? the way I did the projectile takes a long time to go up the ramp and I don’t know of any other way. here is a video of it:
as you can see, the projectile goes up very slowly compared to its initial speed, it doesn’t go down and it comes out very laggy on the client
- What solutions have you tried so far? I tried to use raycast to leave the projectile always above the ground but it takes a long time
here is the current code for the projectile to stay on the ground:
local ProjectileHeight = 5
local raycastParams = RaycastParams.new()
spawn(function()
while true do
RunService.Stepped:wait()
local origin = Projectile.Ray.WorldPosition
local raycastResult = workspace:Raycast(origin, Projectile.Ray.WorldCFrame.LookVector * (ProjectileHeight), raycastParams) -- Projectile.Ray is an Attachment
if raycastResult then
Projectile.Position = raycastResult.Position + Vector3.new(0, 5, 0)
end
end
end)
here is the code that makes the projectile move:
local BodyVel = Instance.new("BodyVelocity")
BodyVel.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BodyVel.Velocity = ProjectilePos.WorldCFrame.LookVector * ProjectileSpeed -- ProjectilePos is the attachment from where the projectile will appear
BodyVel.Parent = Projectile