Stepped will get you a good enough result, as for performance it can be situational. PartCache, for all your quick part-creation needs , is great for optimizing situations like tons of bullets flying around.
One method used is to let the server only do the calculations (like hit detection), and the client to draw/simulate the bullet visually.
I have seen it everywhere. FastCast, FastCast, FastCast. I want to do everything for myself, because I think that makes me actually learn it. I also don’t want to rely on some third party module.
Well there are lots of ways to learn something. I recommended FastCast not just as something you can use, but like I explicitly stated, it’s a module that is great to learn from in terms of simulating projectiles in Roblox’s context. The source is entirely open.
Could you give me an example of what making a projectile using RenderStepped would look like, or explain it a little further? (Also stop advertising EtiTheSpirit’s modules, lol)
I don’t have any readily digestable snippets that are better to learn from than FastCast (that I know of). If you just want an example, it’s not hard to draw up yourself, or find something in the toolbox to study. The simplest example of a projectile w/ renderstepped is simply creating a part, then in a RenderStepped CFraming it in a certain direction.
Lastly, I don’t see anything wrong with “advertising” great contributions to the devforum to help explain content.
So, does anyone passing by here happen to know a method of using Body movers? I’m fairly certain that there are ways around the Speed triangle and the Touched event sucking problem. I’d really appreciate that since Free Models (as almost always) don’t give anything useful. Thanks.
If it’s of any help to you, the old module – which used a lower performing object model, mind you (the modern version is FAR faster) – could fire over 600 bullets per second without any lag at all. Of course, Roblox’s replication won’t like you if you spam an event that hard, but the script itself is fast.
Ok, but I’m assuming every Client would have to move the bullets itself, right?
I don’t think to replicating the bullet’s position every to all clients heartbeat is a good idea…
I’d have to fire a Remote a lot then, and that might cause the projectile to appear earlier than for other clients.
Ok so I’m on mobile here but I can point you in the right direction for bodymovers.
So you start with creating a bodyVelocity and make it face the part with some CFrame math(not tested)
local speed = [speed here]
local bv = Instance.new(“BodyVelocity”)
bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.Velocity = (CFrame.new([gun pos], [mouse.Hit pos]).LookVector * Vector3.new(speed, 0, speed) ) + Vector3.new(0,[y velocity to put on bullet], 0)
bv.Parent = [bullet]
I can’t guarantee it works and you’ll have to fiddle with the speed and y velocity, but here is the base of body movers and bullets
Edit: why won’t you work darn codeblicks
Thanks. Looks fine to me, though I probably could’ve done that myself. (Probably, )
Do you have any idea, how hits could be detected, as that’s the actual problem with Bodymovers.
I’m reading a lot of posts using instancing/bodymovers, but it should be known that in larger-scale games, instancing can become pretty heavy on memory, especially in games with large player count.
For projectiles, I use this function: (units = amount of units, per frame, that the projectile will travel; also note that the projectile should be Anchored and CanCollide == false.)
game:GetService("RunService").Heartbeat:Connect(function()
projectile.Position = projectile.Position + projectile.CFrame.LookVector * units
end)
There is nothing wrong with using instancing, but I prefer using this method as it’s a lot easier to manage and control. Additionally, bullet dropoff is possible by multiplying the x-component of the projectile using CFrame.Angles().
In order to detect collisions with your projectile, check out this article that uses the GetTouchingParts() function. It’s (arguably) more accurate than .Touched and less expensive than Raycasting.
Hello, I am the person who wishes to debate this, specifically the second one.
The expense of raycasts increases depending on the length of the cast. Otherwise, firing off rays holds a negligible cost. You can fire off hundreds of rays per frame with no noticeable expense or performance drop.
I’m completely with you, I just recall reading that Instancing (in general) is an expensive process on client or server memory, so I figured that the GetTouchingParts function would be more efficient than raycasting.
Of course it also depends on the type of projectiles that OP is going for. If they’re going for hitscan projectiles, then obviously raycasting would be the more optimal choice.