Should I use CFrame? Bodyvelocity? Raycast? There’s so many and I don’t know which one is the most efficient way. I’d want it to work really well, think something like Ro Ghoul shards if you ever played that game. Can anyone help? I’d be really thankful.
CFrame could either create performance issues or make the projectile move unsmoothly. I honestly prefer BodyVelocity, but Raycasting works too. It really depends on how you want your projectile to work. Are you going to let the projectile continue forever, or slowly lose its speed until it stops?
Last I remember, Ro-Ghoul uses BodyMovers for the shard objects. It really depends on your use case or how you’re willing to implement projectiles. I personally have no experience in projectiles, so I take the lazy route of using raycasting or borrowing projectile code from other sources.
You could ask SushiWalrus himself if he’s willing to share his implementation of projectiles. (cc @SushiWalrus)
Other than that, there are many threads on the DevForum related to projectile motion. You can probably have a look through those and see how developers are creating projectiles, then try adapting some of that into your own works and see if that solves your issue.
I’ve used both raycast and bodyvelocity and both have their own disadvantages.
Raycast is great because it runs smoothly, a bullet visual can easily be tweened to where you hit it actually seems perfect but the disadvantage with it is that damage happens immediately as the shooter clicks on his target so…
Bodyvelocity for ranged weapons is simply put great for some cases, you can make realistic timed damage which is probably why many people like to use it but again there is a problem…
It can lag so terribly much unless you have proper optimization and even then it might lag anyways because several clients have to render a physical bullet which is not ideal.
What I did to implement projectiles was I mixed bodyvelocity with raycasting and it actually worked quite good, basically the shooter would fire and render a bullet which was responsible for sending damage to the server, as the physical bullet was fired all other clients would fire a “dummy” bullet from the shooters gun which was done by tween and raycasting, sounds great right? Not so much.
While the projectile worked fine for me it had big problems as well, firstly having the client handle the damage sent to the server is quite bad because it’s just a gateway for exploiters, my projectile flew fine but when I tried adding bulletdrop it became apparent that mixing Roblox physics with my “simulated” physics it started to have problems so that didn’t work out as I expected.
This shouldn’t discourage you from trying to make a nice projectile system though, there’s always way to make it better than someone and I’m sure you could find better ways to do it than I did.
I’ve used raycasting to make spell effects before and I find them very effective for bullets and other anything else that goes along those lines. Like the people above me said, it really just depends on what you are planning to achieve.
Depends on what shards you’re referring to. If you’re talking about older tech like my previous weapons (Touka1, Kajiri) I set the velocity of the projectile and give it a anti-grav BodyForce
Method 1 Example:
Shard.Anchored = false
Shard.Velocity = HRP.CFrame.lookVector * 100
BodyForce.Force = Vector3.new(0,workspace.Gravity,0) * Shard:GetMass()
On the other hand, if you’re talking about my newer tech such as Taki1 or SSS Owl, I use TweenService.
Method 2 Example:
Shard.Anchored = true
TweenS:Create(Shard,TweenInfo.new(1,0,0),{CFrame = HRP.CFrame + HRP.CFrame.lookVector * 100}):Play()
I don’t know if those are the ‘best’ methods for anything, it’s just what I use. Downside for method 1 would be the delay before it fires, which I got around by using method 2. Downside for method 2, is the projectile doesn’t move smoothly, which you can get around by down the tween on client side of course, but I don’t do that for anti-exploit reasons.
Hitbox wise, if you need help with that feel free to reach a mod in my disc server because I’m very slow to respond on Dev Forums.
The best way I have found out is combining both BodyMovers and raycasting. The projectile is created and handled all locally to ensure no delays between shots and a smooth projectile. A remote is then fired to other clients in range of the projectile in order to create one locally as well, acting as a fake projectile.
Now I know that this is a gateway for exploiters, but adding a lot of checks server side helps circumvent the problem a bit. For example, checking for ammo, range, the frequency that the remote has been fired, etc. And trust me, your nonexploiter players will appreciate it.
There is of course a lot of cases in which using BodyMovers is better over raycasting and vice-versa. It all depends on what you’re trying to achieve.
Its better to use a VectorForce since it has better update rate than the old (i mean leagcy) body movers
Oh, I’m so glad you responded. This is definetely helpful. Thanks!
Mind telling me how you made your trail?
When you click on your screen while holding your wand an event is fired which then adds one single part and then attaches 2 attachments at the very back of the part which then with a repeat loop moves and resizes. Play around with the properties of the trail object to find the best suitable outcome.
More on this, could you write a tutorial on how to script a rocket projectile with networking included please?
what was the property you used
How did you do this. Is there a tutorial I can go to?