Just a quick question relating to projectiles with raycasting
First time using projectiles for raycasting and I just wanted to ask is using tweenservice good?
Heres what I do to handle the dmg:
local projectileTween = TweenService:Create(projectile, TweenInfo.new(0.5), {CFrame = CFrame.new(position)})
projectileTween:Play()
projectileTween.Completed:Connect(function()
print("Doing dmg to Enemy!")
Highlight.HighlightIndicate(eHum.Parent, 2)
eHum:TakeDamage(15)
end)
Is this a bad practice?
Would it be more smarter to check if they are in the raycast hitpart position or whatever?
1 Like
Using tweens for projectiles is not really a good idea.
- If the destination of the tween is further away the projectile will move faster
- You cant really listen to when the tween changes you so you need to just while true do ray cast
Also know if projectiles are the right thing for you, stuff like bullets often don’t need to be projectiles but rather just raycasts. Only reason you would want them to be projectiles is if you want physics to affect it.
I recommend you either use lerp, raycasts and some math to move the projectile in a direction or look into using a popular module called FastCast for handling this sort of stuff.
RunService a good option for this?
Using tweens for projectiles is the worst thing u could do i believe. Its better to use VectorForce for that right?
But yeah, Projectiles don’t need a basepart, they should only appear with a decal on impact (on a basepart(not on a character)).
Raycasting is made for bullets mostly.
I suggest using BodyPosition, it’s deprecated but still works.
I’m sure there is a newer more efficient instance to use but from I’ve worked with, this is just what I would suggest!
Tweens and VectorForces are equally as bad, as with vector forces you have to rely on Roblox Physics and if the bullet hits something it will just fling around. I recommend always using CFrames, Renderstepped and math for projectiles.
1 Like