How do I make a smooth and good projectiles?

What do I want to achive?
I want at least a good projectiles that will detect hits good and that I can control easly. At least some of these arguments I want to achieve. I want make a game that will have a lot of projectiles with different sizes (basically bullet hell game). My game also gonna have some things that will affect on projectiles, like changing it’s speed and etc.

What have I tried?
I have tried:

FastCast Module - It’s better to work with small projectiles like bows, pistols and etc. It’s isn’t very easy to learn and hard to control projectile. - Cleary not what I need

BodyMovers - Not smooth and accurate but easy to use and control. - First 2 issues already means it’s better to not use

RunService - Requires a lot of resource which will make game lag if there a lot of projectiles. - Too laggy

Client side - Exploiters: free real estate. - I don’t don’t want give exploiters ability to create their own projectile.

Tweening + .Touched - Not accurate - Not accurate

What have I searched up
I have read a lot of topics about this theme. In answers I saw only FastCast Module or there wasn’t answer at all. And yes, I was reading replies even if there was answer but it didn’t helped me too.

My thought for next method
I have idea of using tweening service to move projectile. However I have no idea how to detect hit without RunService or While True Loop (btw is While True Loop requires a lot of resources like RunService or no?) .

4 Likes

I’m not sure what you’ve been told but using RunService isn’t expensive unless you either create memory leaks, use inefficient code or are ineffectively using RenderStepped. A simple heartbeat/ stepped event (all though it’s better to be used in a loop) can allow you to have a lot of control over your projectile. TweenService is actually very expensive and I wouldn’t recommend you using it, especially if you intend on having loads of moving parts.

If you use RunService you’ll also be able to deal with the hit detection as you can use Rays, which are once again extremely efficient. I would also recommend drawing projectiles on the client and then doing the detection on the server as that way it helps prevent poor networking.

In total your basics will looks like this:

local RunService = game:GetService("RunService")
local remote = RemoteHere

while RunService.HeartBeat:Wait() do -- Check PS note

   bullet:Draw()
   if bulletHitDetection then
      remote:FireServer() -- Do sanity checks on server
   end
end

PS: I did while RunService.HeartBeat:Wait() do because it stops a new thread being made every time it fires and just keeps it in a loop.

3 Likes

Thanks! I will try this when I will be able to enter my project!